@rg-dev/stdlib 1.0.54 → 1.0.55
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 +11 -1
- package/lib/node-env.d.cts +2 -1
- package/lib/node-env.d.ts +2 -1
- package/lib/node-env.js +11 -1
- package/package.json +1 -1
package/lib/node-env.cjs
CHANGED
|
@@ -212,6 +212,7 @@ __export(node_env_exports, {
|
|
|
212
212
|
createTempDir: () => createTempDir,
|
|
213
213
|
createTempFilePath: () => createTempFilePath,
|
|
214
214
|
getEnvPaths: () => getEnvPaths,
|
|
215
|
+
isHaveRootPrivileges: () => isHaveRootPrivileges,
|
|
215
216
|
isWindows: () => isWindows,
|
|
216
217
|
throwIfDirNotEmpty: () => throwIfDirNotEmpty,
|
|
217
218
|
typedSystemArch: () => typedSystemArch
|
|
@@ -478,7 +479,9 @@ async function checkCommandExistsOrThrow(cmd) {
|
|
|
478
479
|
}
|
|
479
480
|
}
|
|
480
481
|
async function checkIfFileExistsOrThrow(thePath) {
|
|
481
|
-
if (!thePath)
|
|
482
|
+
if (!thePath) {
|
|
483
|
+
throw "path is empty";
|
|
484
|
+
}
|
|
482
485
|
thePath = removeQuotes(thePath);
|
|
483
486
|
if (!await fs.pathExists(thePath)) {
|
|
484
487
|
throw new Error(`path ${thePath} not exists`);
|
|
@@ -494,3 +497,10 @@ function removeQuotes(str) {
|
|
|
494
497
|
return str;
|
|
495
498
|
}
|
|
496
499
|
}
|
|
500
|
+
function isHaveRootPrivileges() {
|
|
501
|
+
var _a;
|
|
502
|
+
if (isWindows()) {
|
|
503
|
+
throw new Error("isHaveRootPrivileges() is linux only");
|
|
504
|
+
}
|
|
505
|
+
return ((_a = process.geteuid) == null ? void 0 : _a.call(process)) === 0;
|
|
506
|
+
}
|
package/lib/node-env.d.cts
CHANGED
|
@@ -110,5 +110,6 @@ declare function createTempFilePath(ext?: string): {
|
|
|
110
110
|
declare function throwIfDirNotEmpty(dirPath: string): Promise<void>;
|
|
111
111
|
declare function checkCommandExistsOrThrow(cmd: string): Promise<void>;
|
|
112
112
|
declare function checkIfFileExistsOrThrow(thePath: string): Promise<void>;
|
|
113
|
+
declare function isHaveRootPrivileges(): boolean;
|
|
113
114
|
|
|
114
|
-
export { SSEClient, SSEResponse, type SystemArch, checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, chmodPlusX, createTempDir, createTempFilePath, getEnvPaths, isWindows, throwIfDirNotEmpty, typedSystemArch };
|
|
115
|
+
export { SSEClient, SSEResponse, type SystemArch, checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, chmodPlusX, createTempDir, createTempFilePath, getEnvPaths, isHaveRootPrivileges, isWindows, throwIfDirNotEmpty, typedSystemArch };
|
package/lib/node-env.d.ts
CHANGED
|
@@ -110,5 +110,6 @@ declare function createTempFilePath(ext?: string): {
|
|
|
110
110
|
declare function throwIfDirNotEmpty(dirPath: string): Promise<void>;
|
|
111
111
|
declare function checkCommandExistsOrThrow(cmd: string): Promise<void>;
|
|
112
112
|
declare function checkIfFileExistsOrThrow(thePath: string): Promise<void>;
|
|
113
|
+
declare function isHaveRootPrivileges(): boolean;
|
|
113
114
|
|
|
114
|
-
export { SSEClient, SSEResponse, type SystemArch, checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, chmodPlusX, createTempDir, createTempFilePath, getEnvPaths, isWindows, throwIfDirNotEmpty, typedSystemArch };
|
|
115
|
+
export { SSEClient, SSEResponse, type SystemArch, checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, chmodPlusX, createTempDir, createTempFilePath, getEnvPaths, isHaveRootPrivileges, isWindows, throwIfDirNotEmpty, typedSystemArch };
|
package/lib/node-env.js
CHANGED
|
@@ -462,7 +462,9 @@ async function checkCommandExistsOrThrow(cmd) {
|
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
async function checkIfFileExistsOrThrow(thePath) {
|
|
465
|
-
if (!thePath)
|
|
465
|
+
if (!thePath) {
|
|
466
|
+
throw "path is empty";
|
|
467
|
+
}
|
|
466
468
|
thePath = removeQuotes(thePath);
|
|
467
469
|
if (!await fs.pathExists(thePath)) {
|
|
468
470
|
throw new Error(`path ${thePath} not exists`);
|
|
@@ -478,6 +480,13 @@ function removeQuotes(str) {
|
|
|
478
480
|
return str;
|
|
479
481
|
}
|
|
480
482
|
}
|
|
483
|
+
function isHaveRootPrivileges() {
|
|
484
|
+
var _a;
|
|
485
|
+
if (isWindows()) {
|
|
486
|
+
throw new Error("isHaveRootPrivileges() is linux only");
|
|
487
|
+
}
|
|
488
|
+
return ((_a = process.geteuid) == null ? void 0 : _a.call(process)) === 0;
|
|
489
|
+
}
|
|
481
490
|
export {
|
|
482
491
|
SSEClient,
|
|
483
492
|
SSEResponse,
|
|
@@ -489,6 +498,7 @@ export {
|
|
|
489
498
|
createTempDir,
|
|
490
499
|
createTempFilePath,
|
|
491
500
|
getEnvPaths,
|
|
501
|
+
isHaveRootPrivileges,
|
|
492
502
|
isWindows,
|
|
493
503
|
throwIfDirNotEmpty,
|
|
494
504
|
typedSystemArch
|