From c59918c7e110228212d77c22a8422f912dba7e9d Mon Sep 17 00:00:00 2001 From: Ricardo Lafuente Date: Fri, 28 May 2021 23:48:56 +0100 Subject: [PATCH 1/5] Use sbot.exe path on win32 --- lib/shoebot.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/shoebot.js b/lib/shoebot.js index a55537c..67ddb3c 100644 --- a/lib/shoebot.js +++ b/lib/shoebot.js @@ -6,6 +6,7 @@ const fs = require('fs'); const path = require('path'); const ConsoleView = require('./console-view'); const config = require('./config'); +const isWin = process.platform === "win32"; export default { process: null, @@ -22,7 +23,7 @@ export default { this.consoleView = new ConsoleView() this.consoleView.initUI() this.sbotDir = path.normalize(atom.config.get("shoebot.shoebot-dir")) - this.sbot = path.join(this.sbotDir, 'bin/sbot') + this.sbot = path.join(this.sbotDir, 'bin/sbot' + (isWin ? ".exe" : "")) this.sbotvideo = path.join(this.sbotDir, 'bin/sbot-video-export') }, From 2156db0eb23b5aa7b9b749e4636440b45735bfa9 Mon Sep 17 00:00:00 2001 From: Ricardo Lafuente Date: Fri, 28 May 2021 23:49:19 +0100 Subject: [PATCH 2/5] better code Co-Authored-By: Stuart Axon --- lib/shoebot.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/shoebot.js b/lib/shoebot.js index 67ddb3c..74548d8 100644 --- a/lib/shoebot.js +++ b/lib/shoebot.js @@ -48,7 +48,7 @@ export default { editor = atom.workspace.getActivePaneItem() scriptFile = editor.buffer.file scriptDir = path.dirname(scriptFile.path) - command = this.sbot + ' --window ' + scriptFile.path + command = `${this.sbot} --window ${scriptFile.path}` console.log("Running command: " + command) if (this.process) { @@ -164,9 +164,9 @@ export default { exportErrormsg = null exportProcess = spawn(command, {shell: true, detached: true, cwd: scriptDir}, (error, stdout, stderr) => { if (error) { - console.log(error.stack); - console.log('Error code: '+error.code); - console.log('Signal received: '+error.signal); + console.error(error.stack); + console.error('Error code: ' + error.code); + console.error('Signal received: ' + error.signal); } }) exportProcess.on('exit', function (code) { From 11c856689ae6970c9fa05953fa96f1184576018e Mon Sep 17 00:00:00 2001 From: Ricardo Lafuente Date: Fri, 28 May 2021 23:55:31 +0100 Subject: [PATCH 3/5] Add link to docs on successful video export --- lib/shoebot.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/shoebot.js b/lib/shoebot.js index 74548d8..f812d27 100644 --- a/lib/shoebot.js +++ b/lib/shoebot.js @@ -172,7 +172,9 @@ export default { exportProcess.on('exit', function (code) { if (!code) { atom.notifications.addSuccess("Export finished!", { - description: "The sketch was output to " + result.filePath, + description: `The sketch was output to ${result.filePath} as a 10 + second video. For other options, use the + [command line export script](https://docs.shoebot.net/getstarted.html#exporting-video).` }) console.log(code) } else { From cfbb3b1ca3277bf79f4eb31830814f8e52fc1466 Mon Sep 17 00:00:00 2001 From: Ricardo Lafuente Date: Sat, 29 May 2021 23:30:03 +0100 Subject: [PATCH 4/5] Use template literals when appropriate --- lib/shoebot.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/shoebot.js b/lib/shoebot.js index f812d27..ca6cba2 100644 --- a/lib/shoebot.js +++ b/lib/shoebot.js @@ -66,7 +66,7 @@ export default { */ this.process = spawn(command, {shell: true, detached: true, cwd: scriptDir}) this.process.on('exit', function (code) { - console.log('Child process exited with exit code '+code); + console.log(`Child process exited with exit code ${code}`); if (errormsg) { atom.notifications.addError("Error running sketch!", { detail: errormsg }) linenumber = parseInt(errormsg.split(":")[0].split(" line ")[1]) @@ -108,20 +108,20 @@ export default { }).then(result => { if (result.filePath) { atom.notifications.addInfo("Exporting sketch...") - command = this.sbot + ' ' + scriptFile.path + ' --outputfile ' + result.filePath + command = `${this.sbot} ${scriptFile.path} --outputfile ${result.filePath}` exportErrormsg = null exportProcess = exec(command, {cwd: scriptDir}, (error, stdout, stderr) => { if (error) { console.log(error.stack); - console.log('Error code: '+error.code); - console.log('Signal received: '+error.signal); + console.error(`Error code: ${error.code}`); + console.error(`Signal received: ${error.signal}`); } }) exportProcess.on('exit', function (code) { if (!exportErrormsg) { atom.notifications.addSuccess("Export finished!", { - description: "The sketch was output to " + result.filePath, + description: `The sketch was output to ${result.filePath}`, }) } else { atom.notifications.addError("Error in export!", { @@ -157,16 +157,16 @@ export default { }).then(result => { if (result.filePath) { atom.notifications.addInfo("Exporting sketch...") - command = ". " + this.sbotDir + "bin/activate && " - command += this.sbotvideo + ' ' + scriptFile.path + ' --outputfile ' + result.filePath + command = `. ${this.sbotDir}bin/activate && ` + command += `${this.sbotvideo} ${scriptFile.path} --outputfile ${result.filePath}` console.log(command) exportErrormsg = null exportProcess = spawn(command, {shell: true, detached: true, cwd: scriptDir}, (error, stdout, stderr) => { if (error) { console.error(error.stack); - console.error('Error code: ' + error.code); - console.error('Signal received: ' + error.signal); + console.error(`Error code: ${error.code}`); + console.error(`Signal received: ${error.signal}`); } }) exportProcess.on('exit', function (code) { From 8e8947f5e611e545d91e0fe6f805fc9a12ef0f43 Mon Sep 17 00:00:00 2001 From: Ricardo Lafuente Date: Wed, 2 Jun 2021 22:39:28 +0100 Subject: [PATCH 5/5] Clarify config setting description --- lib/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/config.js b/lib/config.js index 55c4677..b4f59ba 100644 --- a/lib/config.js +++ b/lib/config.js @@ -3,7 +3,7 @@ export default { 'shoebot-dir': { type:"string", - default:"~/.virtualenvs/shoebot/", - description: `Path where Shoebot was installed`, + default:"/usr/local/", + description: `Path where Shoebot was installed. If you installed Shoebot system-wide, this should be "/usr/local/". If you installed it with virtualenvwrapper, it's "~/virtualenvs/shoebot".`, }, }