feat(CLI): Exit with 1 when diff is not empty.
To make it easier to use the diff command in scripts and CI and to align its API with POSIX diff and diffs on most systems exit with 1 when the diff is not empty. Keep exiting with 0 when it is. Fixes #66.pull/67/head
parent
8f9b344604
commit
3c0c6d7fdb
|
@ -26,4 +26,16 @@ describe('Test the config-sync CLI', () => {
|
||||||
const { stdout } = await exec('yarn cs diff');
|
const { stdout } = await exec('yarn cs diff');
|
||||||
expect(stdout).toContain('No differences between DB and sync directory');
|
expect(stdout).toContain('No differences between DB and sync directory');
|
||||||
});
|
});
|
||||||
|
test('Non-empty diff returns 1', async () => {
|
||||||
|
await exec('rm -rf config/sync/admin-role.strapi-author.json');
|
||||||
|
// Work around Jest not supporting custom error matching.
|
||||||
|
// https://github.com/facebook/jest/issues/8140
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
await exec('yarn cs diff');
|
||||||
|
} catch(e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
expect(error).toHaveProperty('code', 1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -269,7 +269,7 @@ program
|
||||||
{ color: true },
|
{ color: true },
|
||||||
));
|
));
|
||||||
|
|
||||||
process.exit(0);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init table.
|
// Init table.
|
||||||
|
@ -283,7 +283,7 @@ program
|
||||||
// Print table.
|
// Print table.
|
||||||
console.log(table.toString());
|
console.log(table.toString());
|
||||||
|
|
||||||
process.exit(0);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
program.parseAsync(process.argv);
|
program.parseAsync(process.argv);
|
||||||
|
|
Loading…
Reference in New Issue