Initial commit 🎉
fbshipit-source-id: b6fc29740c6875d2e78953b8a7123890a67930f2 Co-authored-by: Sebastian McKenzie <sebmck@fb.com> Co-authored-by: John Knox <jknox@fb.com> Co-authored-by: Emil Sjölander <emilsj@fb.com> Co-authored-by: Pritesh Nandgaonkar <prit91@fb.com>
This commit is contained in:
48
scripts/yarn-install.js
Normal file
48
scripts/yarn-install.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright 2018-present Facebook.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
const {spawn} = require('child_process');
|
||||
const PACKAGES = ['static', 'src/plugins/*', 'src/fb/plugins/*'];
|
||||
const YARN_PATH =
|
||||
process.argv.length > 2 ? path.join(__dirname, process.argv[2]) : 'yarn';
|
||||
|
||||
Promise.all(
|
||||
PACKAGES.map(
|
||||
pattern =>
|
||||
new Promise((resolve, reject) => {
|
||||
glob(
|
||||
path.join(__dirname, '..', pattern, 'package.json'),
|
||||
(err, matches) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(matches);
|
||||
}
|
||||
},
|
||||
);
|
||||
}),
|
||||
),
|
||||
)
|
||||
.then(packages =>
|
||||
Promise.all(
|
||||
packages.reduce((acc, cv) => acc.concat(cv), []).map(
|
||||
pkg =>
|
||||
new Promise(resolve => {
|
||||
const cwd = pkg.replace('/package.json', '');
|
||||
const yarn = spawn(YARN_PATH, ['--mutex', 'file'], {
|
||||
cwd,
|
||||
});
|
||||
yarn.stderr.on('data', e => console.error(e.toString()));
|
||||
yarn.on('close', code => resolve(code));
|
||||
}),
|
||||
),
|
||||
),
|
||||
)
|
||||
// eslint-disable-next-line
|
||||
.then(() => console.log('📦 Installed all dependencies!'));
|
||||
Reference in New Issue
Block a user