storybook/scripts/prepare.js

33 lines
991 B
JavaScript
Raw Normal View History

const path = require('path');
const shell = require('shelljs');
const chalk = require('chalk');
2017-09-29 23:00:47 +03:00
const log = require('npmlog');
2017-09-29 23:00:47 +03:00
const modulePath = path.resolve('./');
// eslint-disable-next-line import/no-dynamic-require
const packageJson = require(path.join(modulePath, 'package.json'));
2017-05-18 09:14:29 +02:00
shell.rm('-rf', 'dist');
const babel = path.join(__dirname, '..', 'node_modules', '.bin', 'babel');
const args = [
'--ignore tests,__tests__,test.js,stories/,story.jsx',
'--plugins "transform-runtime"',
'./src --out-dir ./dist',
2017-04-18 20:37:04 +07:00
'--copy-files',
].join(' ');
const command = `${babel} ${args}`;
const { code } = shell.exec(command, { silent: true });
2017-09-29 23:00:47 +03:00
if (code !== 0) {
log.error(`FAILED: ${chalk.bold(`${packageJson.name}@${packageJson.version}`)}`);
shell.exit(code);
}
const licence = path.join(__dirname, '..', 'LICENSE');
shell.cp(licence, './');
2017-09-29 23:00:47 +03:00
// eslint-disable-next-line no-console
2017-09-29 23:00:47 +03:00
console.log(chalk.gray(`Built: ${chalk.bold(`${packageJson.name}@${packageJson.version}`)}`));