UNPKG

@enplug/scripts

Version:
35 lines (29 loc) 1.13 kB
#! /usr/bin/env node 'use strict'; const commandLineArgs = require('command-line-args'); const sh = require('shelljs'); const path = require('path'); const rootPath = __dirname.split('node_modules')[0]; const loadDevPrivateFile = require('./functions/loadDevPrivateFile'); const checkScriptsUpToDate = require('./functions/checkScriptsUpToDate'); const pkg = require(path.join(rootPath, 'package.json')); // Parse inline arguments const optionDefinitions = [ { name: 'host', alias: 'h', type: String }, { name: 'port', alias: 'p', type: Number }, { name: 'configuration', type: String }, ]; const options = commandLineArgs(optionDefinitions); function runServe() { const devPrivateFile = loadDevPrivateFile(rootPath); const host = options.host || 'localhost.enplug.in'; let command = `ng serve --port=${options.port} --ssl true --host ${host} --ssl-cert "${devPrivateFile.cert}" --ssl-key "${devPrivateFile.key}"`; if (options.configuration) { command += ` --configuration=${options.configuration}`; } sh.exec(command); } checkScriptsUpToDate(pkg).then( () => runServe(), err => console.log(err) );