Merge pull request #67 from goodhoko/feat-diff-exit-status
feat(CLI): Exit with 1 when diff is not empty.pull/77/head
commit
bfd571a7a9
|
@ -102,6 +102,7 @@ yarn.lock
|
||||||
|
|
||||||
testApp
|
testApp
|
||||||
coverage
|
coverage
|
||||||
|
/config/sync
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Strapi
|
# Strapi
|
||||||
|
|
|
@ -6,6 +6,13 @@ const exec = util.promisify(require('child_process').exec);
|
||||||
jest.setTimeout(20000);
|
jest.setTimeout(20000);
|
||||||
|
|
||||||
describe('Test the config-sync CLI', () => {
|
describe('Test the config-sync CLI', () => {
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
// Remove the generated files and the DB.
|
||||||
|
await exec('rm -rf config/sync');
|
||||||
|
await exec('rm -rf .tmp');
|
||||||
|
});
|
||||||
|
|
||||||
test('Export', async () => {
|
test('Export', async () => {
|
||||||
const { stdout } = await exec('yarn cs export -y');
|
const { stdout } = await exec('yarn cs export -y');
|
||||||
expect(stdout).toContain('Finished export');
|
expect(stdout).toContain('Finished export');
|
||||||
|
@ -19,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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
"@strapi/plugin-users-permissions": "^4.0.0",
|
"@strapi/plugin-users-permissions": "^4.0.0",
|
||||||
"@strapi/strapi": "^4.0.0",
|
"@strapi/strapi": "^4.0.0",
|
||||||
"sqlite3": "5.0.2",
|
"sqlite3": "5.0.2",
|
||||||
"strapi-plugin-config-sync": "boazpoolman/strapi-plugin-config-sync"
|
"strapi-plugin-config-sync": "./.."
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "A Strapi developer"
|
"name": "A Strapi developer"
|
||||||
|
|
|
@ -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