2017-04-16 18:11:44 +07:00
|
|
|
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-04-16 18:11:44 +07:00
|
|
|
|
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
|
|
|
|
2017-05-16 08:16:22 +02:00
|
|
|
shell.rm('-rf', 'dist');
|
2017-04-16 18:11:44 +07:00
|
|
|
|
2017-05-16 08:16:22 +02:00
|
|
|
const babel = path.join(__dirname, '..', 'node_modules', '.bin', 'babel');
|
2017-04-16 18:11:44 +07:00
|
|
|
const args = [
|
2017-04-28 08:58:01 -04:00
|
|
|
'--ignore tests,__tests__,test.js,stories/,story.jsx',
|
2017-04-27 22:33:36 +02:00
|
|
|
'--plugins "transform-runtime"',
|
2017-04-16 18:11:44 +07:00
|
|
|
'./src --out-dir ./dist',
|
2017-04-18 20:37:04 +07:00
|
|
|
'--copy-files',
|
2017-04-16 18:11:44 +07:00
|
|
|
].join(' ');
|
|
|
|
|
2017-05-16 08:16:22 +02:00
|
|
|
const command = `${babel} ${args}`;
|
2017-11-02 04:40:48 +03:00
|
|
|
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}`)}`);
|
2017-04-27 23:59:23 +02:00
|
|
|
shell.exit(code);
|
|
|
|
}
|
2017-05-16 08:16:22 +02:00
|
|
|
|
|
|
|
const licence = path.join(__dirname, '..', 'LICENSE');
|
|
|
|
shell.cp(licence, './');
|
2017-09-29 23:00:47 +03:00
|
|
|
|
2017-10-02 01:40:46 +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}`)}`));
|