1 | import * as program from 'commander';
|
2 | import * as path from 'path';
|
3 | import * as shell from 'shelljs';
|
4 | import { Component } from './component';
|
5 | import { exit, isNutmegComponent, notifyOfUpdate, nutmegDir, tsconfigPath } from './utils';
|
6 |
|
7 | notifyOfUpdate();
|
8 |
|
9 | program.command('build <path>', 'compile a Web Component')
|
10 | .parse(process.argv);
|
11 |
|
12 | const workingDir = path.resolve(process.cwd(), program.args[0]);
|
13 | const webpackConfigFile = path.resolve(nutmegDir, 'webpack.component.config.js');
|
14 | const tag = Component.tagFromPackage(workingDir);
|
15 | const tscCmd = `tsc --project ${tsconfigPath(workingDir)} --watch`;
|
16 | const webpackCmd = `webpack-dev-server --config ${webpackConfigFile} --env.tag=${tag} --env.workingDir=${workingDir} --open`;
|
17 |
|
18 | exit("Directory doesn't have a package.json with @nutmeg/seed as a dependancy.", !isNutmegComponent(workingDir));
|
19 |
|
20 | shell.exec(`npx ${tscCmd} & npx ${webpackCmd}`);
|