Files
flipper/scripts/yarn-install.js
Daniel Büchele 1b072c71a7 use yarn network mutex
Summary: The file system mutex caused some problems in Sandcastle. This diffs switches for the default setting (network mutex) in the hope this fixes the problem

Reviewed By: passy

Differential Revision: D9132069

fbshipit-source-id: 5abb4d33b6db2a5d2b3f0788116ca6941e554591
2018-08-02 05:43:33 -07:00

60 lines
1.5 KiB
JavaScript

/**
* 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 {exec} = require('child_process');
const PACKAGES = ['static', 'src/plugins/*', 'src/fb/plugins/*'];
const WINDOWS = /^win/.test(process.platform);
const YARN_PATH =
process.argv.length > 2
? path.join(__dirname, process.argv[2])
: 'yarn' + (WINDOWS ? '.cmd' : '');
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, reject) => {
const cwd = pkg.replace('/package.json', '');
exec(
YARN_PATH,
{
cwd,
},
(err, stderr, stdout) => {
if (err) {
reject(err);
} else {
resolve(0);
}
},
);
}),
),
),
)
// eslint-disable-next-line
.then(() => console.log('📦 Installed all dependencies!'));