sunnah 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sunnah might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/bin/index.js +17 -6
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -12,6 +12,10 @@ const pkg = JSON.parse(
12
12
  fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"),
13
13
  );
14
14
 
15
+ // ── Windows compatibility ─────────────────────────────────────────────────────
16
+ const isWin = process.platform === "win32";
17
+ const NPM = isWin ? "npm.cmd" : "npm";
18
+
15
19
  // ── Colors ────────────────────────────────────────────────────────────────────
16
20
  const c = {
17
21
  reset: "\x1b[0m",
@@ -117,7 +121,6 @@ function animateInstall(pkgName) {
117
121
  let stageIdx = 0;
118
122
  let npmDone = false;
119
123
 
120
- // Print initial bar on its own line
121
124
  process.stdout.write(drawBar(stages[0].label, 0) + "\n");
122
125
 
123
126
  const tick = () => {
@@ -128,14 +131,12 @@ function animateInstall(pkgName) {
128
131
  const step = (stage.end - prevEnd) / 22;
129
132
  percent = Math.min(percent + step, stage.end);
130
133
 
131
- // Overwrite the bar line
132
134
  process.stdout.write("\r\x1b[K");
133
135
  process.stdout.write(drawBar(stage.label, percent));
134
136
 
135
137
  if (percent >= stage.end) {
136
138
  stageIdx++;
137
139
  if (stageIdx >= stages.length) {
138
- // All visual stages done — wait for npm
139
140
  const poll = setInterval(() => {
140
141
  if (npmDone) {
141
142
  clearInterval(poll);
@@ -154,10 +155,17 @@ function animateInstall(pkgName) {
154
155
 
155
156
  setTimeout(tick, stages[0].ms);
156
157
 
157
- // Actually run npm install -g
158
- const proc = spawn("npm", ["install", "-g", pkgName], {
158
+ // spawn npm.cmd on Windows, npm on Unix
159
+ const proc = spawn(NPM, ["install", "-g", pkgName], {
159
160
  stdio: ["ignore", "pipe", "pipe"],
161
+ shell: isWin,
162
+ });
163
+
164
+ proc.on("error", () => {
165
+ // resolve anyway so the UI doesn't hang on spawn failure
166
+ npmDone = true;
160
167
  });
168
+
161
169
  proc.on("close", () => {
162
170
  npmDone = true;
163
171
  });
@@ -167,7 +175,10 @@ function animateInstall(pkgName) {
167
175
  // ── Check if a package is already installed globally ─────────────────────────
168
176
  function isInstalled(name) {
169
177
  try {
170
- execSync(`npm list -g ${name} --depth=0 2>/dev/null`, { stdio: "ignore" });
178
+ execSync(`${NPM} list -g ${name} --depth=0`, {
179
+ stdio: "ignore",
180
+ shell: isWin,
181
+ });
171
182
  return true;
172
183
  } catch {
173
184
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sunnah",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Interactive CLI installer for Sunnah hadith npm packages",
5
5
  "bin": {
6
6
  "sunnah": "./bin/index.js"