Use rechoir and interpret for scripts.#258
Conversation
|
Looks like a good addition. Does anyone else in the community want support for these languages? |
|
The notion of being able to automatically use Babel to transpile the script sounds fairly appealing to me. |
|
@ariporad @arturadib what do you guys think? Is it worth the dependency? I have yet to test if this handles exit codes properly and things such as that (which I think are more important than supporting arbitrary languages) |
|
agreed @nfischer , if nothing breaks like exit codes, that's fine. I don't think we have tests for |
|
Sounds like a good idea. I might be able to write up some basic unit tests in bash for shjs, just to make sure that stderr and exit code are preserved (since exec() used to have issues with those) |
|
Once #304 lands, we can see if this breaks shjs. |
|
@knpwrs: Could you rebase off master? Thanks! |
|
@knpwrs most of your stuff you should keep. Make sure this is compatible with file names with spaces and node binary paths with spaces, that's all |
|
Travis failed on one version of node. Appveyor failed a test that I was trying to fix locally on my Mac. I don't currently have access to a Windows machine to debug. |
|
@knpwrs This passes travis. I think someone wrote a bad test for |
|
@knpwrs I dug through the results on my windows 7 box. I see errors that look like If you'd like to debug, feel free to use appveyor as you wish (you can push commits with helpful logging statements, and remove them later). Otherwise, I vote to close the issue, since it isn't worth losing Windows support. |
|
@knpwrs: What's the status on this? I'd really like to get this merged, I miss not having ES6 in my shelljs scripts. |
|
I've just been super busy. My only real option for testing on Windows is a VM, but I don't think I'll really be able to get anywhere this week. |
|
I can take a look. |
|
Alright this PR has more than a bunch of issues.
After fixing all of the above, there is only one change needed to fix the issue reported by @nfischer, which is changing The incremental diff is attached. diff --git a/bin/shjs b/bin/shjs
index 9ad0e1a..75ca58b 100755
--- a/bin/shjs
+++ b/bin/shjs
@@ -36,4 +36,4 @@ var path = require('path');
var extensions = require('interpret').extensions;
var rechoir = require('rechoir');
rechoir.prepare(extensions, scriptName);
-require(require.resolve(path.join(process.cwd(), scriptName)));
+require(require.resolve(path.resolve(process.cwd(), scriptName)));
diff --git a/test/shjs.js b/test/shjs.js
index 02380a6..8b95faa 100644
--- a/test/shjs.js
+++ b/test/shjs.js
@@ -4,8 +4,8 @@ var assert = require('assert');
function runScript(name) {
// prefix with 'node ' for Windows, don't prefix for OSX/Linux
- var cmd = (process.platform === 'win32' ? 'node' : '') + path.resolve(__dirname, '../bin/shjs');
- var script = path.join('resources', 'shjs', name);
+ var cmd = (process.platform === 'win32' ? 'node ' : '') + path.resolve(__dirname, '../bin/shjs');
+ var script = path.resolve(__dirname, 'resources', 'shjs', name);
return shell.exec(cmd + ' ' + script, { silent: true });
}
|
|
@TimothyGu thanks! Awesome work! |
|
@TimothyGu @knpwrs Could we get this rebased? I think most of the blocking issues have been resolved. Thanks! |
|
I refactored this into an up-to-date PR (see #384). It seems to be passing CI so far. If that one is good, I think we should go with that and close this one. |

This adds support for babel, iced coffeescript, typescript, jsx (maybe somebody is generating HTML in a script, eh?), etc.
This can be modified to still execute out-of-process which may be desirable because of the
require('../global')statement. Alternatively, we could require non-globally and leave everything in theshjsfile.