docusaurus/__tests__/validate-package-json.test.ts
Rhys Arkins 6930e91508
fix: add repository metadata to all packages (#3613)
* fix: add repository metadata to all packages

* empty commit for cla bot

* move validate-package-json.test.ts + add glob devDependency

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2020-10-21 15:05:01 +02:00

32 lines
1 KiB
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import util from 'util';
import globCb from 'glob';
import fsCb from 'fs';
const glob = util.promisify(globCb);
const readFile = util.promisify(fsCb.readFile);
describe('packages', () => {
test('should contain repository and directory for every package', async () => {
const allPackageJson = await glob('packages/*/package.json');
expect(allPackageJson.length).toBeGreaterThan(0);
/* eslint-disable no-await-in-loop,no-restricted-syntax */
for (const packageJson of allPackageJson) {
const content = JSON.parse(await readFile(packageJson, 'utf8'));
if (content.private !== true) {
expect(content.repository).toEqual({
type: 'git',
url: 'https://github.com/facebook/docusaurus.git',
directory: packageJson.replace(/\/package\.json$/, ''),
});
}
}
});
});