2017-04-16 18:11:44 +07:00
|
|
|
const path = require('path');
|
|
|
|
const shell = require('shelljs');
|
|
|
|
const chalk = require('chalk');
|
|
|
|
|
2017-05-16 08:16:22 +02:00
|
|
|
const packageJson = require('../package.json');
|
2017-05-18 09:14:29 +02:00
|
|
|
|
2017-05-16 08:16:22 +02:00
|
|
|
shell.echo(chalk.bold(`${packageJson.name}@${packageJson.version}`));
|
|
|
|
|
|
|
|
shell.echo(chalk.gray('\n=> Clean dist.'));
|
|
|
|
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-04-27 18:19:06 +02:00
|
|
|
shell.echo(chalk.gray('\n=> Transpiling "src" into ES5 ...\n'));
|
2017-05-16 08:16:22 +02:00
|
|
|
shell.echo(chalk.gray(command));
|
2017-04-16 18:11:44 +07:00
|
|
|
shell.echo('');
|
2017-05-16 08:16:22 +02:00
|
|
|
const code = shell.exec(command).code;
|
2017-04-27 23:59:23 +02:00
|
|
|
if (code === 0) {
|
|
|
|
shell.echo(chalk.gray('\n=> Transpiling completed.'));
|
|
|
|
} else {
|
|
|
|
shell.exit(code);
|
|
|
|
}
|
2017-05-16 08:16:22 +02:00
|
|
|
|
|
|
|
const licence = path.join(__dirname, '..', 'LICENSE');
|
|
|
|
shell.echo(chalk.gray('\n=> Copy LICENSE.'));
|
|
|
|
shell.cp(licence, './');
|