@rg-dev/stdlib 1.0.6 → 1.0.7

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.
package/lib/node-env.cjs CHANGED
@@ -190,6 +190,7 @@ __export(node_env_exports, {
190
190
  checkCommandExistsOrThrow: () => checkCommandExistsOrThrow,
191
191
  checkIfDirExistsOrThrow: () => checkIfDirExistsOrThrow,
192
192
  checkIfFileExistsOrThrow: () => checkIfFileExistsOrThrow,
193
+ chmodPlusX: () => chmodPlusX,
193
194
  createTempDir: () => createTempDir,
194
195
  isWindows: () => isWindows,
195
196
  throwIfDirNotEmpty: () => throwIfDirNotEmpty
@@ -202,6 +203,19 @@ var import_command_exists = __toESM(require_command_exists2(), 1);
202
203
  function isWindows() {
203
204
  return import_os.default.platform() === "win32";
204
205
  }
206
+ function chmodPlusX(filePath) {
207
+ if (import_os.default.platform() === "win32") {
208
+ return;
209
+ }
210
+ try {
211
+ const resolvedPath = import_path.default.resolve(filePath);
212
+ const stats = fs.statSync(resolvedPath);
213
+ const newMode = stats.mode | 73;
214
+ fs.chmodSync(resolvedPath, newMode);
215
+ } catch (e) {
216
+ console.error(`Failed to chmod +x ${filePath}:`, String((e == null ? void 0 : e.message) || e));
217
+ }
218
+ }
205
219
  async function checkIfDirExistsOrThrow(path2) {
206
220
  if (!path2)
207
221
  throw "path is empty";
@@ -1,8 +1,9 @@
1
1
  declare function isWindows(): boolean;
2
+ declare function chmodPlusX(filePath: string): void;
2
3
  declare function checkIfDirExistsOrThrow(path: string): Promise<void>;
3
4
  declare function createTempDir(): string;
4
5
  declare function throwIfDirNotEmpty(dir_path: string): Promise<void>;
5
6
  declare function checkCommandExistsOrThrow(cmd: string): Promise<void>;
6
7
  declare function checkIfFileExistsOrThrow(the_path: string): Promise<void>;
7
8
 
8
- export { checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, createTempDir, isWindows, throwIfDirNotEmpty };
9
+ export { checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, chmodPlusX, createTempDir, isWindows, throwIfDirNotEmpty };
package/lib/node-env.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  declare function isWindows(): boolean;
2
+ declare function chmodPlusX(filePath: string): void;
2
3
  declare function checkIfDirExistsOrThrow(path: string): Promise<void>;
3
4
  declare function createTempDir(): string;
4
5
  declare function throwIfDirNotEmpty(dir_path: string): Promise<void>;
5
6
  declare function checkCommandExistsOrThrow(cmd: string): Promise<void>;
6
7
  declare function checkIfFileExistsOrThrow(the_path: string): Promise<void>;
7
8
 
8
- export { checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, createTempDir, isWindows, throwIfDirNotEmpty };
9
+ export { checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, chmodPlusX, createTempDir, isWindows, throwIfDirNotEmpty };
package/lib/node-env.js CHANGED
@@ -194,6 +194,19 @@ import path from "path";
194
194
  function isWindows() {
195
195
  return os.platform() === "win32";
196
196
  }
197
+ function chmodPlusX(filePath) {
198
+ if (os.platform() === "win32") {
199
+ return;
200
+ }
201
+ try {
202
+ const resolvedPath = path.resolve(filePath);
203
+ const stats = fs.statSync(resolvedPath);
204
+ const newMode = stats.mode | 73;
205
+ fs.chmodSync(resolvedPath, newMode);
206
+ } catch (e) {
207
+ console.error(`Failed to chmod +x ${filePath}:`, String((e == null ? void 0 : e.message) || e));
208
+ }
209
+ }
197
210
  async function checkIfDirExistsOrThrow(path2) {
198
211
  if (!path2)
199
212
  throw "path is empty";
@@ -246,6 +259,7 @@ export {
246
259
  checkCommandExistsOrThrow,
247
260
  checkIfDirExistsOrThrow,
248
261
  checkIfFileExistsOrThrow,
262
+ chmodPlusX,
249
263
  createTempDir,
250
264
  isWindows,
251
265
  throwIfDirNotEmpty
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rg-dev/stdlib",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",