Skip to content

Commit

Permalink
Bug 1525030 - add a meta test to ensure package.json's don't grow bad…
Browse files Browse the repository at this point in the history
… props
  • Loading branch information
djmitche committed Apr 3, 2019
1 parent 668765b commit d9195f6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/meta_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const exec = util.promisify(require('child_process').exec);
const _ = require('lodash');
const yaml = require('js-yaml');
const depcheck = require('depcheck');
const glob = require('glob');

const ROOT_DIR = path.join(__dirname, '..');

Expand Down Expand Up @@ -100,4 +101,26 @@ suite('Repo Meta Tests', function() {
assert(Object.keys(missing).length === 0, `Missing dependencies: ${JSON.stringify(missing, null, 2)}`);
});

test('workspace package.jsons do not have forbidden fields', async function() {
const packageJsons = glob.sync(
'{services,libraries}/*/package.json',
{cwd: ROOT_DIR});

const forbidden = [
'engines',
'engineStrict',
'engine-strict',
'dependencies',
'devDependencies',
'files',
];
for (let filename of packageJsons) {
const pj = JSON.parse(fs.readFileSync(filename));
for (let prop of forbidden) {
if (pj[prop]) {
throw new Error(`${filename} contains forbidden property ${prop}`);
}
}
}
});
});

0 comments on commit d9195f6

Please sign in to comment.