| 1 |
From: |
| 2 |
Subject: Debian changes |
| 3 |
|
| 4 |
The Debian packaging of node-postcss-advanced-variables is maintained in git, using a workflow |
| 5 |
similar to the one described in dgit-maint-merge(7). |
| 6 |
The Debian delta is represented by this one combined patch; there isn't a |
| 7 |
patch queue that can be represented as a quilt series. |
| 8 |
|
| 9 |
A detailed breakdown of the changes is available from their canonical |
| 10 |
representation -- git commits in the packaging repository. |
| 11 |
For example, to see the changes made by the Debian maintainer in the first |
| 12 |
upload of upstream version 1.2.3, you could use: |
| 13 |
|
| 14 |
% git clone https://git.dgit.debian.org/node-postcss-advanced-variables |
| 15 |
% cd node-postcss-advanced-variables |
| 16 |
% git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian' |
| 17 |
|
| 18 |
(If you have dgit, use `dgit clone node-postcss-advanced-variables`, rather than plain `git clone`.) |
| 19 |
|
| 20 |
We don't use debian/source/options single-debian-patch because it has bugs. |
| 21 |
Therefore, NMUs etc. may nevertheless have made additional patches. |
| 22 |
|
| 23 |
--- |
| 24 |
|
| 25 |
diff --git a/package.json b/package.json |
| 26 |
index 4893635..5635bfc 100644 |
| 27 |
--- a/package.json |
| 28 |
+++ b/package.json |
| 29 |
@@ -22,9 +22,7 @@ |
| 30 |
"engines": { |
| 31 |
"node": ">=18" |
| 32 |
}, |
| 33 |
- "dependencies": { |
| 34 |
- "@csstools/sass-import-resolve": "^1.0.0" |
| 35 |
- }, |
| 36 |
+ "dependencies": {}, |
| 37 |
"peerDependencies": { |
| 38 |
"postcss": "^8.4" |
| 39 |
}, |
| 40 |
diff --git a/src/index.js b/src/index.js |
| 41 |
index d32615b..bdb97d2 100644 |
| 42 |
--- a/src/index.js |
| 43 |
+++ b/src/index.js |
| 44 |
@@ -1,6 +1,6 @@ |
| 45 |
// tooling |
| 46 |
import transformNode from './lib/transform-node'; |
| 47 |
-import resolve from '@csstools/sass-import-resolve'; |
| 48 |
+import resolve from './lib/resolve-import'; |
| 49 |
|
| 50 |
const matchProtocol = /^(?:[A-z]+:)?\/\//; |
| 51 |
|
| 52 |
diff --git a/src/lib/resolve-import.js b/src/lib/resolve-import.js |
| 53 |
new file mode 100644 |
| 54 |
index 0000000..0fd3ab0 |
| 55 |
--- /dev/null |
| 56 |
+++ b/src/lib/resolve-import.js |
| 57 |
@@ -0,0 +1,49 @@ |
| 58 |
+import fs from 'fs'; |
| 59 |
+import path from 'path'; |
| 60 |
+ |
| 61 |
+export default function resolveImport(id, { cwd, readFile = false, cache = {} } = {}) { |
| 62 |
+ const file = getImportCandidates(id, cwd || process.cwd()).find(isFile); |
| 63 |
+ |
| 64 |
+ if (!file) { |
| 65 |
+ throw new Error(`Could not resolve ${id}`); |
| 66 |
+ } |
| 67 |
+ |
| 68 |
+ const resolved = { file }; |
| 69 |
+ |
| 70 |
+ if (readFile) { |
| 71 |
+ resolved.contents = cache[file] || fs.readFileSync(file, 'utf8'); |
| 72 |
+ cache[file] = resolved.contents; |
| 73 |
+ } |
| 74 |
+ |
| 75 |
+ return resolved; |
| 76 |
+} |
| 77 |
+ |
| 78 |
+function getImportCandidates(id, cwd) { |
| 79 |
+ const pathname = path.resolve(cwd, id); |
| 80 |
+ const parsed = path.parse(pathname); |
| 81 |
+ const names = parsed.ext ? [pathname] : [ |
| 82 |
+ pathname, |
| 83 |
+ `${pathname}.css`, |
| 84 |
+ `${pathname}.scss` |
| 85 |
+ ]; |
| 86 |
+ |
| 87 |
+ return names.flatMap(name => { |
| 88 |
+ const dir = path.dirname(name); |
| 89 |
+ const base = path.basename(name); |
| 90 |
+ |
| 91 |
+ return [ |
| 92 |
+ name, |
| 93 |
+ path.join(dir, `_${base}`), |
| 94 |
+ path.join(name, 'index.css'), |
| 95 |
+ path.join(name, 'index.scss') |
| 96 |
+ ]; |
| 97 |
+ }); |
| 98 |
+} |
| 99 |
+ |
| 100 |
+function isFile(file) { |
| 101 |
+ try { |
| 102 |
+ return fs.statSync(file).isFile(); |
| 103 |
+ } catch { |
| 104 |
+ return false; |
| 105 |
+ } |
| 106 |
+} |