Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Commit 1b6e85e

Browse files
Merge pull request #13 from livestorm/liv-5119-plugins-cli-watch-not-watching-subfolders
feat: watch subfolders, liv-5119
2 parents c68bab0 + 07c1172 commit 1b6e85e

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"cliff": "^0.1.10",
1717
"command-line-args": "^5.1.1",
1818
"node-fetch": "^2.6.1",
19+
"node-watch": "^0.7.2",
1920
"prompts": "^2.4.0",
2021
"rimraf": "^3.0.2"
2122
}

src/cmds/watch.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ const fs = require('fs')
22
const { execSync } = require('child_process')
33
const getLivestormPluginInformation = require('../helpers/getLivestormPluginInformation')
44
const env = process.argv[3]
5+
const nodeWatch = require('node-watch');
56

6-
function updatePlugin() {
7+
8+
function updatePlugin(evt, name) {
9+
console.log('%s changed', name);
710
process.stdout.write('\x1b[0m.\x1b[0m')
811

912
const res = execSync(`livestorm publish ${env || ''}`).toString()
@@ -16,9 +19,15 @@ function updatePlugin() {
1619
}
1720

1821
module.exports = function watch() {
19-
const config = getLivestormPluginInformation(env)
22+
getLivestormPluginInformation(env)
2023
console.log(`${env ? `Will publish to ${env}, ` : ''}waiting for file change...`)
2124

22-
fs.watch(process.cwd(), updatePlugin)
23-
if (fs.existsSync(`${process.cwd()}/src`)) fs.watch(`${process.cwd()}/src`, updatePlugin)
25+
nodeWatch('./', {
26+
recursive: true,
27+
filter: (f, skip) => {
28+
if (/\/node_modules/.test(f)) return skip;
29+
if (/\/build/.test(f)) return skip;
30+
return true
31+
},
32+
}, updatePlugin);
2433
}

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ node-fetch@^2.6.1:
138138
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
139139
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
140140

141+
node-watch@^0.7.2:
142+
version "0.7.2"
143+
resolved "https://registry.yarnpkg.com/node-watch/-/node-watch-0.7.2.tgz#545f057da8500487eb8287adcb4cb5a7338d7e21"
144+
integrity sha512-g53VjSARRv1JdST0LZRIg8RiuLr1TaBbVPsVvxh0/0Ymvi0xYUjDuoqQQAWtHJQUXhiShowPT/aXKNeHBcyQsw==
145+
141146
once@^1.3.0:
142147
version "1.4.0"
143148
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"

0 commit comments

Comments
 (0)