2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-05-15 11:59:37 +03:00
Files
bbob/scripts/pkg-task
Nikolay Kostyurin 2ee5141d8e feat: update all deps versions, move from babel to swc
- move all package commands to scripts/pkg-task
- jest now uses swc
- rollup now uses swc
- move all benchmark packages to benchmark/package.json
2021-10-17 19:57:00 +02:00

36 lines
1.1 KiB
JavaScript
Executable File

#!/usr/bin/env node
'use strict';
const { resolve } = require('path')
const { spawn } = require('child_process')
const { Command } = require('commander');
const program = new Command();
const nmBinDir = resolve(`../../node_modules/.bin/`)
const shell = { cmd: 'sh', arg: '-c' }
const actionCommand = (command) => () => {
spawn(shell.cmd, [shell.arg, `${nmBinDir}/${command}`], {
env: process.env,
cwd: process.cwd(),
stdio: 'inherit',
})
}
const commandMap = {
'build-commonjs': `cross-env BABEL_ENV=commonjs NODE_ENV=production ${nmBinDir}/swc --config-file ../../.swcrc-commonjs --out-dir lib src`,
'build-es': `cross-env BABEL_ENV=es NODE_ENV=production ${nmBinDir}/swc --out-dir es src`,
'build-umd': `cross-env BABEL_ENV=rollup NODE_ENV=production ${nmBinDir}/rollup --config ../../rollup.config.js`,
test: `jest`,
cover: `jest --config ../../jest.config.js --coverage .`,
lint: `eslint .`,
bundlesize: `cross-env NODE_ENV=production ${nmBinDir}/bundlesize .`
}
program.version('1.0.0')
for (const [key, command] of Object.entries(commandMap)) {
program.command(key).action(actionCommand(command))
}
program.parse();