Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/shjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ function runWithShjs(name, ...args) {
const execPath = process.platform === 'win32'
? `${JSON.stringify(shell.config.execPath)} `
: '';
if (!name) {
return shell.exec(`${execPath}${binPath}`, {
silent: true
});
}
const script = path.resolve(__dirname, 'resources', 'shjs', name);
let argString = args.map(arg => JSON.stringify(arg)).join(' ');
if (argString) {
Expand Down Expand Up @@ -83,3 +88,17 @@ test('disallow require-ing', t => {
{ instanceOf: Error },
'Executable-only module should not be required');
});

test('Script file does not exist', t => {
const result = runWithShjs('fake-file.js');
t.is(result.code, 1);
t.regex(result.stdout, /^ShellJS: script not found.*fake-file\.js.*/);
t.falsy(result.stderr);
});

test('Missing script file name argument', t => {
const result = runWithShjs();
t.is(result.code, 1);
t.regex(result.stdout, /^ShellJS: missing argument \(script name\).*/);
t.falsy(result.stderr);
});