fsevents 2.0.7 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/nodejs.yml +26 -0
- package/LICENSE +1 -1
- package/README.md +10 -6
- package/fsevents.js +34 -21
- package/fsevents.node +0 -0
- package/package.json +7 -4
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Node CI
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
|
8
|
+
runs-on: macOS-latest
|
9
|
+
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
node-version: [8, 10, 12]
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v1
|
16
|
+
- name: Node v${{ matrix.node-version }}
|
17
|
+
uses: actions/setup-node@v1
|
18
|
+
with:
|
19
|
+
node-version: ${{ matrix.node-version }}
|
20
|
+
- name: npm install, build, and test
|
21
|
+
run: |
|
22
|
+
npm install
|
23
|
+
npm run build --if-present
|
24
|
+
npm test
|
25
|
+
env:
|
26
|
+
CI: true
|
package/LICENSE
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
MIT License
|
2
2
|
-----------
|
3
3
|
|
4
|
-
Copyright (C) 2010-2019 by Philipp Dunkel, Ben Noordhuis, Elan Shankar
|
4
|
+
Copyright (C) 2010-2019 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller
|
5
5
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
@@ -11,6 +11,8 @@ uses fsevents, check out [Chokidar](https://github.com/paulmillr/chokidar).
|
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
14
|
+
Supports only **Node.js v8.16 and higher**.
|
15
|
+
|
14
16
|
```sh
|
15
17
|
npm install fsevents
|
16
18
|
```
|
@@ -28,13 +30,15 @@ stop(); // To end observation
|
|
28
30
|
The callback passed as the second parameter to `.watch` get's called whenever the operating system detects a
|
29
31
|
a change in the file system. It takes three arguments:
|
30
32
|
|
31
|
-
`(path:
|
33
|
+
###### `fsevents.watch(dirname: string, (path: string, flags: number, id: string) => void): Function`
|
32
34
|
|
33
|
-
* `path` - the item in the filesystem that have been changed
|
34
|
-
* `flags` - a numeric value describing what the change was
|
35
|
-
* `id` - an unique-id identifying this specific event
|
35
|
+
* `path: string` - the item in the filesystem that have been changed
|
36
|
+
* `flags: number` - a numeric value describing what the change was
|
37
|
+
* `id: string` - an unique-id identifying this specific event
|
38
|
+
|
39
|
+
Returns closer callback.
|
36
40
|
|
37
|
-
###### `fsevents.getInfo(path, flags, id): FsEventInfo
|
41
|
+
###### `fsevents.getInfo(path: string, flags: number, id: string): FsEventInfo`
|
38
42
|
|
39
43
|
The `getInfo` function takes the `path`, `flags` and `id` arguments and converts those parameters into a structure
|
40
44
|
that is easier to digest to determine what the change was.
|
@@ -62,6 +66,6 @@ The `FsEventsInfo` has the following shape:
|
|
62
66
|
|
63
67
|
## License
|
64
68
|
|
65
|
-
The MIT License Copyright (C) 2010-
|
69
|
+
The MIT License Copyright (C) 2010-2019 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller — see LICENSE file.
|
66
70
|
|
67
71
|
Visit our [GitHub page](https://github.com/fsevents/fsevents) and [NPM Page](https://npmjs.org/package/fsevents)
|
package/fsevents.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
|
-
** © 2018 by Philipp Dunkel, Ben Noordhuis, Elan Shankar
|
3
|
-
** Licensed under MIT License.
|
4
|
-
*/
|
2
|
+
** © 2018 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller
|
3
|
+
** Licensed under MIT License.
|
4
|
+
*/
|
5
5
|
|
6
6
|
/* jshint node:true */
|
7
7
|
'use strict';
|
@@ -11,11 +11,15 @@ if (process.platform !== 'darwin') {
|
|
11
11
|
}
|
12
12
|
|
13
13
|
const Native = require('./fsevents.node');
|
14
|
-
const
|
14
|
+
const events = Native.constants;
|
15
15
|
|
16
16
|
function watch(path, handler) {
|
17
|
-
if (
|
18
|
-
|
17
|
+
if (typeof path !== 'string') {
|
18
|
+
throw new TypeError(`fsevents argument 1 must be a string and not a ${typeof path}`);
|
19
|
+
}
|
20
|
+
if (typeof handler !== 'function') {
|
21
|
+
throw new TypeError(`fsevents argument 2 must be a function and not a ${typeof handler}`);
|
22
|
+
}
|
19
23
|
|
20
24
|
let instance = Native.start(path, handler);
|
21
25
|
if (!instance) throw new Error(`could not watch: ${path}`);
|
@@ -25,9 +29,11 @@ function watch(path, handler) {
|
|
25
29
|
return result;
|
26
30
|
};
|
27
31
|
}
|
32
|
+
|
28
33
|
function getInfo(path, flags) {
|
29
34
|
return {
|
30
|
-
path,
|
35
|
+
path,
|
36
|
+
flags,
|
31
37
|
event: getEventType(flags),
|
32
38
|
type: getFileType(flags),
|
33
39
|
changes: getFileChanges(flags)
|
@@ -35,28 +41,35 @@ function getInfo(path, flags) {
|
|
35
41
|
}
|
36
42
|
|
37
43
|
function getFileType(flags) {
|
38
|
-
if (
|
39
|
-
if (
|
40
|
-
if (
|
44
|
+
if (events.ItemIsFile & flags) return 'file';
|
45
|
+
if (events.ItemIsDir & flags) return 'directory';
|
46
|
+
if (events.ItemIsSymlink & flags) return 'symlink';
|
47
|
+
}
|
48
|
+
function anyIsTrue(obj) {
|
49
|
+
for (let key in obj) {
|
50
|
+
if (obj[key]) return true;
|
51
|
+
}
|
52
|
+
return false;
|
41
53
|
}
|
42
54
|
function getEventType(flags) {
|
43
|
-
if (
|
44
|
-
if (
|
45
|
-
if (
|
46
|
-
if (
|
47
|
-
if (
|
48
|
-
|
55
|
+
if (events.ItemRemoved & flags) return 'deleted';
|
56
|
+
if (events.ItemRenamed & flags) return 'moved';
|
57
|
+
if (events.ItemCreated & flags) return 'created';
|
58
|
+
if (events.ItemModified & flags) return 'modified';
|
59
|
+
if (events.RootChanged & flags) return 'root-changed';
|
60
|
+
if (events.ItemCloned & flags) return 'cloned';
|
61
|
+
if (anyIsTrue(flags)) return 'modified';
|
49
62
|
return 'unknown';
|
50
63
|
}
|
51
64
|
function getFileChanges(flags) {
|
52
65
|
return {
|
53
|
-
inode: !!(
|
54
|
-
finder: !!(
|
55
|
-
access: !!(
|
56
|
-
xattrs: !!(
|
66
|
+
inode: !!(events.ItemInodeMetaMod & flags),
|
67
|
+
finder: !!(events.ItemFinderInfoMod & flags),
|
68
|
+
access: !!(events.ItemChangeOwner & flags),
|
69
|
+
xattrs: !!(events.ItemXattrMod & flags)
|
57
70
|
};
|
58
71
|
}
|
59
72
|
|
60
73
|
exports.watch = watch;
|
61
74
|
exports.getInfo = getInfo;
|
62
|
-
exports.constants =
|
75
|
+
exports.constants = events;
|
package/fsevents.node
CHANGED
Binary file
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "fsevents",
|
3
|
-
"version": "2.0
|
4
|
-
"description": "Native Access to
|
3
|
+
"version": "2.1.0",
|
4
|
+
"description": "Native Access to MacOS FSEvents",
|
5
5
|
"main": "fsevents.js",
|
6
6
|
"os": [
|
7
7
|
"darwin"
|
@@ -39,12 +39,15 @@
|
|
39
39
|
{
|
40
40
|
"name": "Miroslav Bajtoš",
|
41
41
|
"email": "mbajtoss@gmail.com"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"name": "Paul Miller",
|
45
|
+
"url": "https://paulmillr.com"
|
42
46
|
}
|
43
47
|
],
|
44
48
|
"license": "MIT",
|
45
49
|
"bugs": {
|
46
50
|
"url": "https://github.com/fsevents/fsevents/issues"
|
47
51
|
},
|
48
|
-
"homepage": "https://github.com/fsevents/fsevents"
|
49
|
-
"devDependencies": {}
|
52
|
+
"homepage": "https://github.com/fsevents/fsevents"
|
50
53
|
}
|