create-cookbook 1.0.0-beta.1 → 1.0.0-beta.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.
Files changed (2) hide show
  1. package/index.mjs +6 -5
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -182,10 +182,10 @@ const utils = {
182
182
  if (!existsSync(pathChecked)) mkdirSync(pathChecked);
183
183
  if (existsSync(join(pathChecked, filename))) {
184
184
  if (pathChecked.startsWith("/home")) await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
185
- else await utils.executeBash(`sudo rm -f ${join(pathChecked, filename)}`);
185
+ else await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
186
186
  }
187
187
  if (pathChecked.startsWith("/home")) await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
188
- else await utils.executeBash(`sudo mv ${join(workspace, filename)} ${pathChecked} && sudo chmod +x ${join(pathChecked, filename)}`);
188
+ else await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
189
189
  }
190
190
  if (process.platform === "darwin") {
191
191
  const paths = [join(process.env.HOME, "bin"), join(process.env.HOME, ".bin"), join(process.env.HOME, ".local", "bin"), "/usr/local/bin"];
@@ -203,10 +203,10 @@ const utils = {
203
203
  if (!existsSync(pathChecked)) mkdirSync(pathChecked);
204
204
  if (existsSync(join(pathChecked, filename))) {
205
205
  if (pathChecked.startsWith("/Users")) await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
206
- else await utils.executeBash(`sudo rm -f ${join(pathChecked, filename)}`);
206
+ else await utils.executeBash(`rm -f ${join(pathChecked, filename)}`);
207
207
  }
208
208
  if (pathChecked.startsWith("/Users")) await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
209
- else await utils.executeBash(`sudo mv ${join(workspace, filename)} ${pathChecked} && sudo chmod +x ${join(pathChecked, filename)}`);
209
+ else await utils.executeBash(`mv ${join(workspace, filename)} ${pathChecked} && chmod +x ${join(pathChecked, filename)}`);
210
210
  }
211
211
  },
212
212
  executePowershell: async (script) => {
@@ -215,7 +215,8 @@ const utils = {
215
215
  });
216
216
  },
217
217
  executeBash: (script) => {
218
- return execFileSync("bash", ["-c", script], {
218
+
219
+ return execFileSync("bash", ["-c", `if command -v sudo &>/dev/null; then sudo ${script}; else ${script}; fi`], {
219
220
  stdio: "inherit",
220
221
  });
221
222
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-cookbook",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
4
4
  "main": "index.mjs",
5
5
  "bin": {
6
6
  "create-cookbook": "./index.mjs"