Skip to content

Commit caa9de5

Browse files
committed
Add Sandbox watcher pausing
1 parent 77ba531 commit caa9de5

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"husky": "^4.2.5",
1919
"is": "^3.3.0",
2020
"lint-staged": "^10.1.5",
21+
"ospath": "^1.2.2",
2122
"puppeteer": "^2.1.1",
2223
"tap-spec": "^5.0.0",
2324
"tape": "^4.13.2",
@@ -30,7 +31,7 @@
3031
},
3132
"husky": {
3233
"hooks": {
33-
"pre-commit": "touch ./._pause-sandbox-watcher && lint-staged && rm ./._pause-sandbox-watcher",
34+
"pre-commit": "PAUSE=true ./scripts/pause-sandbox && lint-staged && PAUSE=false ./scripts/pause-sandbox",
3435
"pre-push": "npm run test"
3536
}
3637
},

scripts/pause-sandbox

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /usr/bin/env node
2+
3+
/**
4+
* Pauses the Sandbox watcher to ensure pre-commit hooks don't accidentally initiate hydration
5+
*/
6+
const fs = require('fs')
7+
const path = require('path')
8+
const osPath = require('ospath')
9+
const pauseFile = path.join(osPath.tmp(), '_pause-architect-sandbox-watcher')
10+
11+
const status = process.env.PAUSE
12+
13+
try {
14+
if (status === 'true') {
15+
if (!fs.existsSync(pauseFile)) {
16+
fs.writeFileSync(pauseFile, '\n')
17+
}
18+
}
19+
if (status === 'false') {
20+
if (fs.existsSync(pauseFile)) {
21+
fs.unlinkSync(pauseFile)
22+
}
23+
}
24+
}
25+
catch (err) { /* noop */ }

0 commit comments

Comments
 (0)