Skip to content

Commit 6d100d0

Browse files
fix: Ensuring the sw flag is a boolean in watch mode (#1595)
Co-authored-by: Leah <[email protected]>
1 parent 5117f46 commit 6d100d0

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

.changeset/tender-carrots-sniff.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'preact-cli': patch
3+
---
4+
5+
Ensuring the sw flag is a boolean in watch mode

packages/cli/lib/commands/build.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ const rimraf = require('rimraf');
22
const { resolve } = require('path');
33
const { promisify } = require('util');
44
const runWebpack = require('../lib/webpack/run-webpack');
5+
const { toBool } = require('../util');
56
const { validateArgs } = require('./validate-args');
67

7-
const toBool = val => val === void 0 || (val === 'false' ? false : val);
8-
98
const options = [
109
{
1110
name: '--src',

packages/cli/lib/commands/watch.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const runWebpack = require('../lib/webpack/run-webpack');
2-
const { warn } = require('../util');
2+
const { toBool, warn } = require('../util');
33
const { validateArgs } = require('./validate-args');
44

55
const options = [
@@ -101,6 +101,7 @@ async function command(src, argv) {
101101
}
102102
argv.src = src || argv.src;
103103
argv.production = false;
104+
argv.sw = toBool(argv.sw);
104105

105106
if (argv.https || process.env.HTTPS) {
106107
let { key, cert, cacert } = argv;

packages/cli/lib/util.js

+4
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ exports.normalizeTemplatesResponse = function (repos = []) {
5050
description: repo.description || '',
5151
}));
5252
};
53+
54+
exports.toBool = function (val) {
55+
return val === void 0 || (val === 'false' ? false : val);
56+
};

0 commit comments

Comments
 (0)