Skip to content

Commit

Permalink
[build.js] target -> part
Browse files Browse the repository at this point in the history
  • Loading branch information
rexim committed Nov 22, 2023
1 parent e0f2e14 commit cfc2fac
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const child_process = require("child_process");
const spawn = child_process.spawn;

// TODO: promisify cmd
function cmd(program, args) {
console.log('CMD:', program, args);
const p = spawn(program, args);
Expand Down Expand Up @@ -45,26 +46,27 @@ function tscServiceWorker(...extraParams) {
]);
}

function build(target, ...args) {
if (target === undefined) {
function build(part, ...args) {
if (part === undefined) {
tscServiceWorker();
tscMain();
} else if (target === 'main') {
} else if (part === 'main') {
tscMain();
} else if (target === 'serviceworker') {
} else if (part === 'serviceworker') {
tscServiceWorker();
} else {
throw new Error(`Unknown build target {target}`);
throw new Error(`Unknown build part {part}`);
}
}

function watch(target, ...args) {
if (target === undefined || target === 'main') {
function watch(part, ...args) {
if (part === undefined || part === 'main') {
// TODO: is it possible to watch both parts?
tscMain('-w');
} else if (target === 'serviceworker') {
} else if (part === 'serviceworker') {
tscServiceWorker('-w');
} else {
throw new Error(`Unknown watch target {target}`);
throw new Error(`Unknown watch part {part}`);
}
}

Expand Down

0 comments on commit cfc2fac

Please sign in to comment.