@appland/scanner 1.74.2 → 1.74.4

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [@appland/scanner-v1.74.4](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.74.3...@appland/scanner-v1.74.4) (2023-01-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Make sure telemetry event aggregation doesn't prevent exit ([41b19ba](https://github.com/getappmap/appmap-js/commit/41b19ba27e64042b8e1b4757d41ee548c2710c9e))
7
+ * Make sure to watch the correct directory in the scanner ([8f6f96a](https://github.com/getappmap/appmap-js/commit/8f6f96a5f79d0feaf0064a7ee363e82c1b7dfe22))
8
+
9
+ # [@appland/scanner-v1.74.3](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.74.2...@appland/scanner-v1.74.3) (2022-12-21)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * Examine errors based on error code instead of error message ([f2c15e8](https://github.com/getappmap/appmap-js/commit/f2c15e8e0b2dfce270fc3d92c2bd64fa775947d7))
15
+
1
16
  # [@appland/scanner-v1.74.2](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.74.1...@appland/scanner-v1.74.2) (2022-12-16)
2
17
 
3
18
 
@@ -92,13 +92,13 @@ class Watcher {
92
92
  this.configWatcher
93
93
  .on('add', this.reloadConfig.bind(this))
94
94
  .on('change', this.reloadConfig.bind(this));
95
- const appmapDir = path_1.default.resolve(this.options.appmapDir);
95
+ const cwd = process.cwd();
96
+ // note: sometimes path.resolve doesn't seem to use the correct cwd unless it's provided explicitly
97
+ const appmapDir = path_1.default.resolve(cwd, this.options.appmapDir);
96
98
  // If the appmap directory is a descendant of cwd, watch cwd (presumably project directory).
97
99
  // This ensures the watch will survive even if the appmap dir is removed and recreated.
98
100
  // Otherwise, make sure to use an existing directory. Chokidar struggles with missing directories.
99
- const watchDir = isAncestorPath(process.cwd(), appmapDir)
100
- ? process.cwd()
101
- : yield existingParent(appmapDir);
101
+ const watchDir = isAncestorPath(cwd, appmapDir) ? cwd : yield existingParent(appmapDir);
102
102
  // Custom ignore function needed to cut down the watch tree to just what we need.
103
103
  const ignored = (targetPath) => {
104
104
  // Ignore anything that isn't an ancestor or descendant of the appmap dir.
@@ -128,11 +128,14 @@ class Watcher {
128
128
  .on('error', this.watcherErrorFunction.bind(this));
129
129
  });
130
130
  }
131
+ isError(error, code) {
132
+ const err = error;
133
+ return err.code === code;
134
+ }
131
135
  watcherErrorFunction(error) {
132
136
  var _a;
133
137
  return __awaiter(this, void 0, void 0, function* () {
134
- if (this.appmapWatcher &&
135
- error.message.includes('ENOSPC: System limit for number of file watchers reached')) {
138
+ if (this.appmapWatcher && this.isError(error, 'ENOSPC')) {
136
139
  console.warn(error.stack);
137
140
  console.warn('Will disable file watching. File polling will stay enabled.');
138
141
  yield ((_a = this.appmapWatcher) === null || _a === void 0 ? void 0 : _a.close());
@@ -8,7 +8,7 @@ class EventAggregator {
8
8
  this.callback = callback;
9
9
  this.maxMsBetween = maxMsBetween;
10
10
  this.pending = [];
11
- process.on('exit', () => {
11
+ process.on('beforeExit', () => {
12
12
  if (this.timeout) {
13
13
  clearTimeout(this.timeout);
14
14
  this.emitPending();
@@ -22,7 +22,7 @@ class EventAggregator {
22
22
  refresh() {
23
23
  if (this.timeout)
24
24
  clearTimeout(this.timeout);
25
- this.timeout = setTimeout(this.emitPending.bind(this), this.maxMsBetween);
25
+ this.timeout = setTimeout(this.emitPending.bind(this), this.maxMsBetween).unref();
26
26
  }
27
27
  emitPending() {
28
28
  this.callback(this.pending);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appland/scanner",
3
- "version": "1.74.2",
3
+ "version": "1.74.4",
4
4
  "description": "Analyze AppMaps for code flaws",
5
5
  "bin": "built/cli.js",
6
6
  "files": [