diff --git a/packages/browsers/package.json b/packages/browsers/package.json index 79cd39e0..2c84b64a 100644 --- a/packages/browsers/package.json +++ b/packages/browsers/package.json @@ -5,7 +5,7 @@ "scripts": { "build:docs": "wireit", "build": "wireit", - "clean": "git clean -Xf $(ls -A | grep -v node_modules)", + "clean": "../../tools/clean.js", "test": "wireit" }, "bin": "lib/cjs/main-cli.js", diff --git a/packages/ng-schematics/package.json b/packages/ng-schematics/package.json index 6472cd79..c1443fd6 100644 --- a/packages/ng-schematics/package.json +++ b/packages/ng-schematics/package.json @@ -4,7 +4,7 @@ "description": "Puppeteer Angular schematics", "scripts": { "build": "wireit", - "clean": "git clean -Xf $(ls -A | grep -v node_modules)", + "clean": "../../tools/clean.js", "dev:test": "npm run test --watch", "dev": "npm run build --watch", "sandbox:test": "node tools/sandbox.js --test", diff --git a/packages/puppeteer-core/package.json b/packages/puppeteer-core/package.json index 3815e77d..d62ebdc4 100644 --- a/packages/puppeteer-core/package.json +++ b/packages/puppeteer-core/package.json @@ -37,7 +37,7 @@ "build:docs": "wireit", "build": "wireit", "check": "tsx tools/ensure-correct-devtools-protocol-package", - "clean": "git clean -Xf $(ls -A | grep -v node_modules)", + "clean": "../../tools/clean.js", "prepack": "wireit", "unit": "wireit" }, diff --git a/packages/puppeteer/package.json b/packages/puppeteer/package.json index 2c18af33..b4fc5564 100644 --- a/packages/puppeteer/package.json +++ b/packages/puppeteer/package.json @@ -36,7 +36,7 @@ "scripts": { "build:docs": "wireit", "build": "wireit", - "clean": "git clean -Xf $(ls -A | grep -v node_modules)", + "clean": "../../tools/clean.js", "postinstall": "node install.js", "prepack": "wireit" }, diff --git a/packages/testserver/package.json b/packages/testserver/package.json index 84b544fd..6190cf83 100644 --- a/packages/testserver/package.json +++ b/packages/testserver/package.json @@ -5,7 +5,7 @@ "main": "lib/index.js", "scripts": { "build": "wireit", - "clean": "git clean -Xf $(ls -A | grep -v node_modules)" + "clean": "../../tools/clean.js" }, "wireit": { "build": { diff --git a/test/installation/package.json b/test/installation/package.json index 49d8a5ac..67c3c8ad 100644 --- a/test/installation/package.json +++ b/test/installation/package.json @@ -5,7 +5,7 @@ "private": true, "scripts": { "build": "wireit", - "clean": "git clean -Xf $(ls -A | grep -v node_modules)", + "clean": "../../tools/clean.js", "test": "mocha" }, "wireit": { diff --git a/test/package.json b/test/package.json index 123f8841..8f97ca95 100644 --- a/test/package.json +++ b/test/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "wireit", - "clean": "git clean -Xf $(ls -A | grep -v node_modules)" + "clean": "../tools/clean.js" }, "wireit": { "build": { diff --git a/tools/clean.js b/tools/clean.js new file mode 100755 index 00000000..049fdc04 --- /dev/null +++ b/tools/clean.js @@ -0,0 +1,12 @@ +#!/usr/bin/env node + +const {exec} = require('child_process'); +const {readdirSync} = require('fs'); + +exec( + `git clean -Xf ${readdirSync(process.cwd()) + .filter(file => { + return file !== 'node_modules'; + }) + .join(' ')}` +);