storybook/lib/cli/src/npm_init.js

16 lines
358 B
JavaScript

import { spawn } from 'cross-spawn';
import { hasYarn } from './has_yarn';
const packageManager = hasYarn() ? 'yarn' : 'npm';
export function npmInit() {
const results = spawn.sync(packageManager, ['init', '-y'], {
cwd: process.cwd(),
env: process.env,
stdio: 'pipe',
encoding: 'utf-8',
silent: true,
});
return results.stdout;
}