main
Last change
on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago |
Pred finalna verzija
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[0c6b92a] | 1 | const {createWrapper} = require('./wrapper');
|
---|
| 2 |
|
---|
| 3 | let name = `@parcel/watcher-${process.platform}-${process.arch}`;
|
---|
| 4 | if (process.platform === 'linux') {
|
---|
| 5 | const { MUSL, family } = require('detect-libc');
|
---|
| 6 | if (family === MUSL) {
|
---|
| 7 | name += '-musl';
|
---|
| 8 | } else {
|
---|
| 9 | name += '-glibc';
|
---|
| 10 | }
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | let binding;
|
---|
| 14 | try {
|
---|
| 15 | binding = require(name);
|
---|
| 16 | } catch (err) {
|
---|
| 17 | handleError(err);
|
---|
| 18 | try {
|
---|
| 19 | binding = require('./build/Release/watcher.node');
|
---|
| 20 | } catch (err) {
|
---|
| 21 | handleError(err);
|
---|
| 22 | try {
|
---|
| 23 | binding = require('./build/Debug/watcher.node');
|
---|
| 24 | } catch (err) {
|
---|
| 25 | handleError(err);
|
---|
| 26 | throw new Error(`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.`);
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | function handleError(err) {
|
---|
| 32 | if (err?.code !== 'MODULE_NOT_FOUND') {
|
---|
| 33 | throw err;
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | const wrapper = createWrapper(binding);
|
---|
| 38 | exports.writeSnapshot = wrapper.writeSnapshot;
|
---|
| 39 | exports.getEventsSince = wrapper.getEventsSince;
|
---|
| 40 | exports.subscribe = wrapper.subscribe;
|
---|
| 41 | exports.unsubscribe = wrapper.unsubscribe;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.