Debian Codegraph @

node/@parcel/watcher/index.js

raw
1 const {createWrapper} = require('./wrapper');
2
3 let name = `@parcel/watcher-${process.platform}-${process.arch}`;
4 if (process.platform === 'linux') {
5 const {MUSL, familySync} = require('detect-libc');
6 const family = familySync();
7 if (family === MUSL) {
8 name += '-musl';
9 } else {
10 name += '-glibc';
11 }
12 }
13
14 let binding;
15 try {
16 binding = require(name);
17 } catch (err) {
18 handleError(err);
19 try {
20 binding = require('./build/Release/watcher.node');
21 } catch (err) {
22 handleError(err);
23 try {
24 binding = require('./build/Debug/watcher.node');
25 } catch (err) {
26 handleError(err);
27 throw new Error(
28 `No prebuild or local build of @parcel/watcher found. Tried ${name}. Please ensure it is installed (don't use --no-optional when installing with npm). Otherwise it is possible we don't support your platform yet. If this is the case, please report an issue to https://github.com/parcel-bundler/watcher.`,
29 );
30 }
31 }
32 }
33
34 function handleError(err) {
35 if (err?.code !== 'MODULE_NOT_FOUND') {
36 throw err;
37 }
38 }
39
40 const wrapper = createWrapper(binding);
41 exports.writeSnapshot = wrapper.writeSnapshot;
42 exports.getEventsSince = wrapper.getEventsSince;
43 exports.subscribe = wrapper.subscribe;
44 exports.unsubscribe = wrapper.unsubscribe;