ghost-portal/scripts/findPackages.js
Jaco Greeff 105205fb46
Auto-add all packages to webpack alias (#798)
* Auto-add all packages to webpack alias

* Use findPackages approach is jest.config as well

* Remove debug log
2019-03-12 13:01:37 +01:00

29 lines
840 B
JavaScript

// Copyright 2017-2019 @polkadot/apps authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
const fs = require('fs');
const path = require('path');
module.exports = function findPackages () {
const pkgRoot = path.join(__dirname, '..', 'packages');
return fs
.readdirSync(pkgRoot)
.filter((entry) => {
const pkgPath = path.join(pkgRoot, entry);
return !['.', '..'].includes(entry) &&
fs.lstatSync(pkgPath).isDirectory() &&
fs.lstatSync(path.join(pkgPath, 'package.json'));
})
.map((dir) => {
const jsonPath = path.join(pkgRoot, dir, 'package.json');
const { name } = JSON.parse(
fs.readFileSync(jsonPath).toString('utf-8')
);
return { dir, name };
});
}