Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let modules = ['es', 'cjs']
if (args.includes('--modules')) {
// eslint-disable-next-line no-unused-vars
const [_, arg] = args.splice(args.indexOf('--modules'), 2)
if (!arg) {
throw new Error('Missing --modules argument')
}
modules = arg.split(',')
if (modules.some(mod => !['es', 'cjs'].includes(mod))) {
throw new Error(`Invalid --modules argument: '${arg}'`)
}
}
const commands = {
es: getCommand('babel', [...babelArgs, '--out-dir', 'es'], [...envVars, 'ES_MODULES=1']),
cjs: getCommand('babel', [...babelArgs, '--out-dir', 'lib'], [...envVars, 'TRANSFORM_IMPORTS=1'])
}
const commandsToRun = modules.reduce((obj, key) => ({ ...obj, [key]: commands[key] }), {})
process.exit(runCommandsConcurrently(commandsToRun).status)
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const { runCommandsConcurrently, getCommand } = require('@instructure/command-utils')
// ui-scripts --server -p 8080
const args = process.argv.slice(2)
const portIndex = args.findIndex(arg => arg === '-p')
let port = '8080'
if (portIndex > 0) {
port = args[portIndex + 1]
}
process.exit(runCommandsConcurrently({
// http-server __build__ -p 8001
server: getCommand('http-server', ['__build__', '-p', port], [])
}).status)
if (args.includes('--modules')) {
// eslint-disable-next-line no-unused-vars
const [_, arg] = args.splice(args.indexOf('--modules'), 2)
if (!arg) {
throw new Error('Missing --modules argument')
}
modules = arg.split(',')
if (modules.some(mod => !['es', 'cjs'].includes(mod))) {
throw new Error(`Invalid --modules argument: '${arg}'`)
}
}
const commands = {
es: getCommand('babel', [...babelArgs, '--out-dir', 'es'], [...envVars, 'ES_MODULES=1']),
cjs: getCommand('babel', [...babelArgs, '--out-dir', 'lib'], [...envVars, 'TRANSFORM_IMPORTS=1'])
}
const commandsToRun = modules.reduce((obj, key) => ({ ...obj, [key]: commands[key] }), {})
process.exit(runCommandsConcurrently(commandsToRun).status)
webpackArgs = ['--mode=development', `--port=${port}`]
} else {
command = 'webpack'
envVars = [
`NODE_ENV=${NODE_ENV || 'production'}`,
'NODE_OPTIONS=--max_old_space_size=120000',
(DEBUG ? `DEBUG=1` : false),
(UNMANGLED_CLASS_NAMES ? `UNMANGLED_CLASS_NAMES=1` : false),
(USE_WEBPACK_CSS_LOADERS ? `USE_WEBPACK_CSS_LOADERS=1` : false),
(DISABLE_SPEEDY_STYLESHEET ? `DISABLE_SPEEDY_STYLESHEET=1` : false)
].filter(Boolean)
webpackArgs = ['--mode=production']
}
process.exit(runCommandsConcurrently({
webpack: getCommand(command, webpackArgs, envVars)
}).status)
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const { runCommandsConcurrently, getCommand } = require('@instructure/command-utils')
process.exit(runCommandsConcurrently({
clean: getCommand('rimraf', [
'__build__',
'es',
'dist',
'lib',
'.babel-cache',
'.cache',
'types'
])
}).status)
} else {
command = 'build-storybook'
commandArgs = ['-c', '.storybook', '-o', '__build__']
envVars = [
`NODE_ENV=production`,
`NODE_PATH=${rootPath}`,
(DEBUG ? `DEBUG=1` : false),
(UNMANGLED_CLASS_NAMES ? `UNMANGLED_CLASS_NAMES=1` : false),
(USE_WEBPACK_CSS_LOADERS ? `USE_WEBPACK_CSS_LOADERS=1` : false),
(DISABLE_SPEEDY_STYLESHEET ? `DISABLE_SPEEDY_STYLESHEET=1` : false)
].filter(Boolean)
}
process.exit(
runCommandsConcurrently({
storybook: getCommand(command, commandArgs, envVars)
}).status
)