@ms-cloudpack/file-watcher 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import { resolve } from 'path';
4
4
  // probably shouldn't be here. I think lage should be responsible for understanding what "bundle" means
5
5
  // (we can provide a definition) and what its inputs are and what it depends on. Then when we call
6
6
  // ensurePackageBundled, lage can ensure watching is happening for the full graph of tasks.
7
- const defaultWatchPaths = ['./package.json', './src'];
7
+ const defaultWatchPaths = ['src/**', '*.json', '!**/node_modules/**'];
8
8
  /**
9
9
  * Creates a watcher which can watch a package and notify the client when it changes.
10
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"createWatcher.js","sourceRoot":"","sources":["../src/createWatcher.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAY/B,sGAAsG;AACtG,uGAAuG;AACvG,kGAAkG;AAClG,2FAA2F;AAC3F,MAAM,iBAAiB,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IACvC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAa,CAAC;IAEtC,OAAO;QACL,KAAK,CAAC,OAAqB,EAAE,gBAA4B;YACvD,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,iBAAiB,EAAE,GAAG,OAAO,CAAC;YACzD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACtG,IAAI,OAA8B,CAAC;YAEnC,IAAI,KAAK,CAAC,MAAM,EAAE;gBAChB,0DAA0D;gBAC1D,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE1C,uGAAuG;gBACvG,uGAAuG;gBACvG,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;gBAE/D,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;aACvB;YAED,sDAAsD;YACtD,OAAO,KAAK,IAAI,EAAE;gBAChB,IAAI,OAAO,EAAE;oBACX,MAAM,CAAC,GAAG,OAAO,CAAC;oBAElB,OAAO,GAAG,SAAS,CAAC;oBACpB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;oBAEnB,KAAK,MAAM,WAAW,IAAI,KAAK,EAAE;wBAC/B,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;qBAClC;oBAED,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;iBACjB;YACH,CAAC,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,UAAU;YACd,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC9D,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,YAAY,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { FSWatcher } from 'chokidar';\nimport chokidar from 'chokidar';\nimport { resolve } from 'path';\n\nexport interface WatchOptions {\n path: string;\n watchPaths?: string[];\n}\n\nexport interface Watcher {\n watch(options: WatchOptions, onPackageChanged: () => void): () => Promise<void>;\n unwatchAll(): Promise<void>;\n}\n\n// TODO: This list of watched paths is hardcoded, but really it shouldn't be. In fact, this whole file\n// probably shouldn't be here. I think lage should be responsible for understanding what \"bundle\" means\n// (we can provide a definition) and what its inputs are and what it depends on. Then when we call\n// ensurePackageBundled, lage can ensure watching is happening for the full graph of tasks.\nconst defaultWatchPaths = ['./package.json', './src'];\n\n/**\n * Creates a watcher which can watch a package and notify the client when it changes.\n */\nexport function createWatcher(): Watcher {\n const watchedPaths = new Set<string>();\n const watchers = new Set<FSWatcher>();\n\n return {\n watch(options: WatchOptions, onPackageChanged: () => void) {\n const { path, watchPaths = defaultWatchPaths } = options;\n const paths = watchPaths.map((relPath) => resolve(path, relPath)).filter((p) => !watchedPaths.has(p));\n let watcher: FSWatcher | undefined;\n\n if (paths.length) {\n // Add paths to watchedPaths to avoid watching them again.\n paths.forEach((p) => watchedPaths.add(p));\n\n // Watch source and register a handler which will rebundle the changed package and notify the client on\n // success. Note that if failures happen, the client will receive the error notification automatically.\n watcher = chokidar.watch(paths).on('change', onPackageChanged);\n\n watchers.add(watcher);\n }\n\n // Return a dispose function to individually clean up.\n return async () => {\n if (watcher) {\n const w = watcher;\n\n watcher = undefined;\n watchers.delete(w);\n\n for (const watchedPath of paths) {\n watchedPaths.delete(watchedPath);\n }\n\n await w.close();\n }\n };\n },\n\n async unwatchAll() {\n await Promise.all(Array.from(watchers).map((w) => w.close()));\n watchers.clear();\n watchedPaths.clear();\n },\n };\n}\n"]}
1
+ {"version":3,"file":"createWatcher.js","sourceRoot":"","sources":["../src/createWatcher.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAY/B,sGAAsG;AACtG,uGAAuG;AACvG,kGAAkG;AAClG,2FAA2F;AAC3F,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,YAAY,GAAG,IAAI,GAAG,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M,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC9D,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,YAAY,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { FSWatcher } from 'chokidar';\nimport chokidar from 'chokidar';\nimport { resolve } from 'path';\n\nexport interface WatchOptions {\n path: string;\n watchPaths?: string[];\n}\n\nexport interface Watcher {\n watch(options: WatchOptions, onPackageChanged: () => void): () => Promise<void>;\n unwatchAll(): Promise<void>;\n}\n\n// TODO: This list of watched paths is hardcoded, but really it shouldn't be. In fact, this whole file\n// probably shouldn't be here. I think lage should be responsible for understanding what \"bundle\" means\n// (we can provide a definition) and what its inputs are and what it depends on. Then when we call\n// ensurePackageBundled, lage can ensure watching is happening for the full graph of tasks.\nconst defaultWatchPaths = ['src/**', '*.json', '!**/node_modules/**'];\n\n/**\n * Creates a watcher which can watch a package and notify the client when it changes.\n */\nexport function createWatcher(): Watcher {\n const watchedPaths = new Set<string>();\n const watchers = new Set<FSWatcher>();\n\n return {\n watch(options: WatchOptions, onPackageChanged: () => void) {\n const { path, watchPaths = defaultWatchPaths } = options;\n const paths = watchPaths.map((relPath) => resolve(path, relPath)).filter((p) => !watchedPaths.has(p));\n let watcher: FSWatcher | undefined;\n\n if (paths.length) {\n // Add paths to watchedPaths to avoid watching them again.\n paths.forEach((p) => watchedPaths.add(p));\n\n // Watch source and register a handler which will rebundle the changed package and notify the client on\n // success. Note that if failures happen, the client will receive the error notification automatically.\n watcher = chokidar.watch(paths).on('change', onPackageChanged);\n\n watchers.add(watcher);\n }\n\n // Return a dispose function to individually clean up.\n return async () => {\n if (watcher) {\n const w = watcher;\n\n watcher = undefined;\n watchers.delete(w);\n\n for (const watchedPath of paths) {\n watchedPaths.delete(watchedPath);\n }\n\n await w.close();\n }\n };\n },\n\n async unwatchAll() {\n await Promise.all(Array.from(watchers).map((w) => w.close()));\n watchers.clear();\n watchedPaths.clear();\n },\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/file-watcher",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "A file watcher abstraction for use with Cloudpack.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18,8 +18,9 @@
18
18
  "chokidar": "^3.5.3"
19
19
  },
20
20
  "devDependencies": {
21
- "@ms-cloudpack/eslint-plugin-internal": "*",
22
- "@ms-cloudpack/scripts": "*"
21
+ "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
22
+ "@ms-cloudpack/scripts": "^0.0.1",
23
+ "@ms-cloudpack/test-utilities": "^0.5.0"
23
24
  },
24
25
  "scripts": {
25
26
  "api": "cloudpack-scripts api",
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.36.4"
9
- }
10
- ]
11
- }