45 lines
996 B
Bash
45 lines
996 B
Bash
|
#!/usr/bin/env node
|
||
|
const child_process = require('child_process');
|
||
|
const fs = require('fs');
|
||
|
const path = require('path');
|
||
|
|
||
|
const glob = require('glob');
|
||
|
const mkdirp = require('mkdirp');
|
||
|
|
||
|
// Package node modules.
|
||
|
mkdirp.sync('package_node_modules');
|
||
|
const modules = [];
|
||
|
for (const package of glob.sync('packages/*')) {
|
||
|
const packageJSON = JSON.parse(
|
||
|
fs.readFileSync(path.join(package, 'package.json'))
|
||
|
);
|
||
|
modules.push(...Object.keys(packageJSON.dependencies || {}));
|
||
|
modules.push(...Object.keys(packageJSON.devDependencies || {}));
|
||
|
}
|
||
|
// Filter out packages.
|
||
|
const remoteModules = modules.filter((module) => {
|
||
|
return 0 !== module.indexOf('@avocado');
|
||
|
})
|
||
|
// Enter and run yarn.
|
||
|
const options = {
|
||
|
cwd: path.join(__dirname, 'package_node_modules'),
|
||
|
stdio: 'inherit',
|
||
|
};
|
||
|
child_process.spawnSync(
|
||
|
'yarn',
|
||
|
[
|
||
|
'init',
|
||
|
'-y',
|
||
|
],
|
||
|
options
|
||
|
);
|
||
|
child_process.spawnSync(
|
||
|
'yarn',
|
||
|
[
|
||
|
'--modules-folder',
|
||
|
options.cwd,
|
||
|
'add'
|
||
|
].concat(remoteModules),
|
||
|
options
|
||
|
);
|