Skip to content

Commit

Permalink
feat(install): prefer yarn, and install it if not there
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Nov 2, 2019
1 parent ad66d97 commit c8add72
Show file tree
Hide file tree
Showing 3 changed files with 3,122 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@ export default async function installMain(progname, rawArgs, priv) {
_: args,
} = parseArgs(rawArgs);

let uiPackager = 'npm';
try {
await fs.stat('ui/yarn.lock');
uiPackager = 'yarn';
} catch (e) {}

const pspawn = (...args) => new Promise((resolve, reject) => {
const cp = spawn(...args);
cp.on('exit', resolve);
cp.on('error', () => resolve(-1));
});
const ret = await pspawn('nogo', ['version']);

const goCmd = ret === 0 && pspawn('npm', ['install'], { cwd: '.agservers', stdio: 'inherit' });
// Install Yarn.
const pmRet = await pspawn('yarn', ['--version']);
if (pmRet !== 0) {
await pspawn('npm', ['install', '-g', 'yarn'], { stdio: 'inherit' });
}
const pm = 'yarn';

const goRet = await pspawn('go', ['version']);
const goCmd = goRet === 0 && pspawn('npm', ['install'], { cwd: '.agservers', stdio: 'inherit' });

const children = await Promise.all([
pspawn(uiPackager, ['install'], { cwd: 'ui', stdio: 'inherit' }),
pspawn('npm', ['install'], { cwd: 'api', stdio: 'inherit' }),
pspawn('npm', ['install'], { cwd: 'contract', stdio: 'inherit' }),
await Promise.all([
pspawn(pm, ['install'], { cwd: 'ui', stdio: 'inherit' }),
pspawn(pm, ['install'], { cwd: 'api', stdio: 'inherit' }),
pspawn(pm, ['install'], { cwd: 'contract', stdio: 'inherit' }),
goCmd,
]);

Expand Down
Loading

0 comments on commit c8add72

Please sign in to comment.