/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
fixtures/packaging/build-all.js
48 строк
1 KB
Dan Abramov
Use Yarn Workspaces (#11252)
19 окт 2017, 02:22
19 окт 2017, 02:22
d9c1dbd
Код
Авторство
О чём код?
const fs = require('fs'); const path = require('path'); const child_process = require('child_process'); const fixtureDirs = fs.readdirSync(__dirname).filter(file => { return fs.statSync(path.join(__dirname, file)).isDirectory(); }); const cmdArgs = [ {cmd: 'yarn', args: ['install']}, {cmd: 'yarn', args: ['build']}, ]; function buildFixture(cmdArg, path) { const opts = { cwd: path, stdio: 'inherit', }; const result = child_process.spawnSync(cmdArg.cmd, cmdArg.args, opts); if (result.status !== 0) { throw new Error(`Failed to build fixtures!`); } } fixtureDirs.forEach(dir => { cmdArgs.forEach(cmdArg => { // we only care about directories that have DEV and PROD directories in // otherwise they don't need to be built const devPath = path.join(__dirname, dir, 'dev'); if (fs.existsSync(devPath)) { buildFixture(cmdArg, devPath); } const prodPath = path.join(__dirname, dir, 'prod'); if (fs.existsSync(prodPath)) { buildFixture(cmdArg, prodPath); } }); }); console.log('-------------------------'); console.log('All fixtures were built!'); console.log('Now ensure all frames display a welcome message:'); console.log(' npm install -g serve'); console.log(' serve ../..'); console.log(' open http://localhost:5000/fixtures/packaging/'); console.log('-------------------------');