Skip to content

Commit fc78654

Browse files
author
Robert Jackson
committed
Fix issue with bin script arguments.
Also, add a test.
1 parent dfa92da commit fc78654

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

commands/global/new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ module.exports.handler = function handler(options) {
115115
require('codemod-cli').runTransform(
116116
__dirname,
117117
process.argv[2] /* transform name */,
118-
process.argv.slice(2) /* paths or globs */
118+
process.argv.slice(3) /* paths or globs */
119119
)
120120
`,
121121
{

tests/cli-test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,49 @@ QUnit.module('codemod-cli', function(hooks) {
188188
});
189189
});
190190

191+
QUnit.module('generated bin script', function(hooks) {
192+
setupProject(hooks);
193+
194+
let userProject;
195+
hooks.beforeEach(
196+
wrap(function*() {
197+
// fix mode of bin script (lost during sharedProject.copy())
198+
fs.chmodSync(codemodProject.path('bin/cli.js'), 0o755);
199+
200+
// includes simple identifier reverser
201+
yield execa(EXECUTABLE_PATH, ['generate', 'codemod', 'main']);
202+
203+
userProject = yield createTempDir();
204+
process.chdir(userProject.path());
205+
})
206+
);
207+
208+
hooks.afterEach(function() {
209+
return userProject.dispose();
210+
});
211+
212+
QUnit.test(
213+
'works with globs',
214+
wrap(function*(assert) {
215+
userProject.write({
216+
foo: {
217+
'something.js': 'let blah = bar',
218+
'other.js': 'let blah = bar',
219+
},
220+
});
221+
222+
yield execa(codemodProject.path('bin/cli.js'), ['main', 'foo/*thing.js']);
223+
224+
assert.deepEqual(userProject.read(), {
225+
foo: {
226+
'something.js': 'let halb = rab',
227+
'other.js': 'let blah = bar',
228+
},
229+
});
230+
})
231+
);
232+
});
233+
191234
QUnit.module('programmatic API', function(hooks) {
192235
setupProject(hooks);
193236

0 commit comments

Comments
 (0)