tailwindcss/patches/@parcel__watcher@2.4.1.patch
2024-08-26 11:08:00 -04:00

57 lines
1.9 KiB
Diff

diff --git a/index.js b/index.js
index 8afb2b1126dcc687b7ff9b631589da252c1f9c22..15d3b2ffa11f8999ab95d8306f789f2a4613bae3 100644
--- a/index.js
+++ b/index.js
@@ -1,40 +1,22 @@
const {createWrapper} = require('./wrapper');
-let name = `@parcel/watcher-${process.platform}-${process.arch}`;
-if (process.platform === 'linux') {
- const { MUSL, family } = require('detect-libc');
- if (family === MUSL) {
- name += '-musl';
- } else {
- name += '-glibc';
- }
-}
+function loadPackage() {
+ if (process.platform === 'linux') {
+ const { MUSL, GLIBC, family } = require("detect-libc");
-let binding;
-try {
- binding = require(name);
-} catch (err) {
- handleError(err);
- try {
- binding = require('./build/Release/watcher.node');
- } catch (err) {
- handleError(err);
- try {
- binding = require('./build/Debug/watcher.node');
- } catch (err) {
- handleError(err);
- 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.`);
+ if (family === MUSL) {
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-musl`);
+ } else if (family === GLIBC) {
+ return require(`@parcel/watcher-${process.platform}-${process.arch}-glibc`);
+ } else {
+ throw new Error(`Unsupported libc on: ${process.platform}-${process.arch}`);
}
+ } else {
+ return require(`@parcel/watcher-${process.platform}-${process.arch}`);
}
}
-function handleError(err) {
- if (err?.code !== 'MODULE_NOT_FOUND') {
- throw err;
- }
-}
-
-const wrapper = createWrapper(binding);
+const wrapper = createWrapper(loadPackage());
exports.writeSnapshot = wrapper.writeSnapshot;
exports.getEventsSince = wrapper.getEventsSince;
exports.subscribe = wrapper.subscribe;