@aneuhold/core-ts-lib 1.0.3 → 1.0.4
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/helperFunctions/cmd.d.ts +3 -0
- package/lib/helperFunctions/cmd.d.ts.map +1 -1
- package/lib/helperFunctions/cmd.js +13 -6
- package/lib/index.d.ts +2 -15
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +16 -15
- package/package.json +9 -7
|
@@ -34,6 +34,9 @@ export type ExecCmdCommandArgument = string | {
|
|
|
34
34
|
* a command regularly outputs an error even when it succeeds. This only
|
|
35
35
|
* applies to commands ran with normal execution.
|
|
36
36
|
*
|
|
37
|
+
* @param cwd the current working directory to run the command in. If not
|
|
38
|
+
* provided, it will use the current working directory of the process.
|
|
39
|
+
*
|
|
37
40
|
* @returns an object that holds the output and the true if the command comlpleted
|
|
38
41
|
* successfully or false if it did not
|
|
39
42
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmd.d.ts","sourceRoot":"","sources":["../../src/helperFunctions/cmd.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,eAAe;;CAG3B,CAAC;
|
|
1
|
+
{"version":3,"file":"cmd.d.ts","sourceRoot":"","sources":["../../src/helperFunctions/cmd.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,eAAe;;CAG3B,CAAC;AAIF,KAAK,iBAAiB,GAAG;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAClE,MAAM,MAAM,sBAAsB,GAC9B,MAAM,GACN;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AA6EzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAA8B,OAAO,CACnC,GAAG,EAAE,sBAAsB,EAC3B,QAAQ,UAAQ,EAChB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,iBAAiB,CAAC,CAwB5B;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,EAAE,SAAO,GACR,OAAO,CAAC,iBAAiB,CAAC,CAQ5B"}
|
|
@@ -41,6 +41,7 @@ const exec = util_1.default.promisify(child_process_1.exec);
|
|
|
41
41
|
exports.variousCommands = {
|
|
42
42
|
pwshExectuablePath: 'Get-Command pwsh | Select-Object -ExpandProperty Definition'
|
|
43
43
|
};
|
|
44
|
+
const POWERSHELL_PREFIX = `pwsh -NoProfile -Command `;
|
|
44
45
|
async function helperExec(cmd, execOptions, logError) {
|
|
45
46
|
try {
|
|
46
47
|
const { stdout, stderr } = await exec(cmd, execOptions);
|
|
@@ -131,6 +132,9 @@ async function helperSpawn(cmd, args, execOptions) {
|
|
|
131
132
|
* a command regularly outputs an error even when it succeeds. This only
|
|
132
133
|
* applies to commands ran with normal execution.
|
|
133
134
|
*
|
|
135
|
+
* @param cwd the current working directory to run the command in. If not
|
|
136
|
+
* provided, it will use the current working directory of the process.
|
|
137
|
+
*
|
|
134
138
|
* @returns an object that holds the output and the true if the command comlpleted
|
|
135
139
|
* successfully or false if it did not
|
|
136
140
|
*/
|
|
@@ -138,16 +142,19 @@ async function execCmd(cmd, logError = false, cwd) {
|
|
|
138
142
|
const execOptions = {
|
|
139
143
|
cwd
|
|
140
144
|
};
|
|
141
|
-
|
|
142
|
-
if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.Windows) {
|
|
143
|
-
execOptions.shell = 'pwsh';
|
|
144
|
-
}
|
|
145
|
+
let modifiedCmd = null;
|
|
145
146
|
if (typeof cmd === 'string') {
|
|
146
147
|
Log_1.default.verbose.info('Command type provided to "execCmd" was a string, so executing "exec" promise...');
|
|
147
|
-
|
|
148
|
+
if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.Windows) {
|
|
149
|
+
modifiedCmd = POWERSHELL_PREFIX + cmd;
|
|
150
|
+
}
|
|
151
|
+
return helperExec(modifiedCmd || cmd, execOptions, logError);
|
|
148
152
|
}
|
|
149
153
|
Log_1.default.verbose.info('Command type provided to "execCmd" was an object, so executing "spawn" promise...');
|
|
150
|
-
|
|
154
|
+
if (CurrentEnv_1.default.os === CurrentEnv_1.OperatingSystemType.Windows) {
|
|
155
|
+
modifiedCmd = POWERSHELL_PREFIX + cmd.command;
|
|
156
|
+
}
|
|
157
|
+
return helperSpawn(modifiedCmd || cmd.command, cmd.args, execOptions);
|
|
151
158
|
}
|
|
152
159
|
exports.default = execCmd;
|
|
153
160
|
/**
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import applications, { AppName } from './helperFunctions/applications/applications';
|
|
1
2
|
import execCmd, { execCmdWithTimeout } from './helperFunctions/cmd';
|
|
2
3
|
import datesAreOnSameDay from './helperFunctions/dateFunctions';
|
|
3
4
|
import findAndInsertText from './helperFunctions/fileFunctions';
|
|
@@ -6,19 +7,5 @@ import sleep from './helperFunctions/sleep';
|
|
|
6
7
|
import getFileNameExtension from './helperFunctions/stringFunctions';
|
|
7
8
|
import CurrentEnv, { OperatingSystemType, ShellType, TerminalType } from './utils/CurrentEnv';
|
|
8
9
|
import Log from './utils/Log';
|
|
9
|
-
|
|
10
|
-
execCmd: typeof execCmd;
|
|
11
|
-
execCmdWithTimeout: typeof execCmdWithTimeout;
|
|
12
|
-
CurrentEnv: typeof CurrentEnv;
|
|
13
|
-
Log: typeof Log;
|
|
14
|
-
sleep: typeof sleep;
|
|
15
|
-
getUserInput: typeof getUserInput;
|
|
16
|
-
findAndInsertText: typeof findAndInsertText;
|
|
17
|
-
OperatingSystemType: typeof OperatingSystemType;
|
|
18
|
-
ShellType: typeof ShellType;
|
|
19
|
-
TerminalType: typeof TerminalType;
|
|
20
|
-
datesAreOnSameDay: typeof datesAreOnSameDay;
|
|
21
|
-
getFileNameExtension: typeof getFileNameExtension;
|
|
22
|
-
};
|
|
23
|
-
export default _default;
|
|
10
|
+
export { execCmd, execCmdWithTimeout, CurrentEnv, applications, AppName, Log, sleep, getUserInput, findAndInsertText, OperatingSystemType, ShellType, TerminalType, datesAreOnSameDay, getFileNameExtension };
|
|
24
11
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,iBAAiB,MAAM,iCAAiC,CAAC;AAChE,OAAO,iBAAiB,MAAM,iCAAiC,CAAC;AAChE,OAAO,YAAY,MAAM,yBAAyB,CAAC;AACnD,OAAO,KAAK,MAAM,yBAAyB,CAAC;AAC5C,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,UAAU,EAAE,EACjB,mBAAmB,EACnB,SAAS,EACT,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,GAAG,MAAM,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EACnB,OAAO,EACR,MAAM,6CAA6C,CAAC;AACrD,OAAO,OAAO,EAAE,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,iBAAiB,MAAM,iCAAiC,CAAC;AAChE,OAAO,iBAAiB,MAAM,iCAAiC,CAAC;AAChE,OAAO,YAAY,MAAM,yBAAyB,CAAC;AACnD,OAAO,KAAK,MAAM,yBAAyB,CAAC;AAC5C,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,UAAU,EAAE,EACjB,mBAAmB,EACnB,SAAS,EACT,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,GAAG,MAAM,aAAa,CAAC;AAG9B,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,OAAO,EACP,GAAG,EACH,KAAK,EACL,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACrB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -26,26 +26,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getFileNameExtension = exports.datesAreOnSameDay = exports.TerminalType = exports.ShellType = exports.OperatingSystemType = exports.findAndInsertText = exports.getUserInput = exports.sleep = exports.Log = exports.AppName = exports.applications = exports.CurrentEnv = exports.execCmdWithTimeout = exports.execCmd = void 0;
|
|
30
|
+
const applications_1 = __importStar(require("./helperFunctions/applications/applications"));
|
|
31
|
+
exports.applications = applications_1.default;
|
|
32
|
+
Object.defineProperty(exports, "AppName", { enumerable: true, get: function () { return applications_1.AppName; } });
|
|
29
33
|
const cmd_1 = __importStar(require("./helperFunctions/cmd"));
|
|
34
|
+
exports.execCmd = cmd_1.default;
|
|
35
|
+
Object.defineProperty(exports, "execCmdWithTimeout", { enumerable: true, get: function () { return cmd_1.execCmdWithTimeout; } });
|
|
30
36
|
const dateFunctions_1 = __importDefault(require("./helperFunctions/dateFunctions"));
|
|
37
|
+
exports.datesAreOnSameDay = dateFunctions_1.default;
|
|
31
38
|
const fileFunctions_1 = __importDefault(require("./helperFunctions/fileFunctions"));
|
|
39
|
+
exports.findAndInsertText = fileFunctions_1.default;
|
|
32
40
|
const input_1 = __importDefault(require("./helperFunctions/input"));
|
|
41
|
+
exports.getUserInput = input_1.default;
|
|
33
42
|
const sleep_1 = __importDefault(require("./helperFunctions/sleep"));
|
|
43
|
+
exports.sleep = sleep_1.default;
|
|
34
44
|
const stringFunctions_1 = __importDefault(require("./helperFunctions/stringFunctions"));
|
|
45
|
+
exports.getFileNameExtension = stringFunctions_1.default;
|
|
35
46
|
const CurrentEnv_1 = __importStar(require("./utils/CurrentEnv"));
|
|
47
|
+
exports.CurrentEnv = CurrentEnv_1.default;
|
|
48
|
+
Object.defineProperty(exports, "OperatingSystemType", { enumerable: true, get: function () { return CurrentEnv_1.OperatingSystemType; } });
|
|
49
|
+
Object.defineProperty(exports, "ShellType", { enumerable: true, get: function () { return CurrentEnv_1.ShellType; } });
|
|
50
|
+
Object.defineProperty(exports, "TerminalType", { enumerable: true, get: function () { return CurrentEnv_1.TerminalType; } });
|
|
36
51
|
const Log_1 = __importDefault(require("./utils/Log"));
|
|
37
|
-
|
|
38
|
-
exports.default = {
|
|
39
|
-
execCmd: cmd_1.default,
|
|
40
|
-
execCmdWithTimeout: cmd_1.execCmdWithTimeout,
|
|
41
|
-
CurrentEnv: CurrentEnv_1.default,
|
|
42
|
-
Log: Log_1.default,
|
|
43
|
-
sleep: sleep_1.default,
|
|
44
|
-
getUserInput: input_1.default,
|
|
45
|
-
findAndInsertText: fileFunctions_1.default,
|
|
46
|
-
OperatingSystemType: CurrentEnv_1.OperatingSystemType,
|
|
47
|
-
ShellType: CurrentEnv_1.ShellType,
|
|
48
|
-
TerminalType: CurrentEnv_1.TerminalType,
|
|
49
|
-
datesAreOnSameDay: dateFunctions_1.default,
|
|
50
|
-
getFileNameExtension: stringFunctions_1.default
|
|
51
|
-
};
|
|
52
|
+
exports.Log = Log_1.default;
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aneuhold/core-ts-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A core library for all of my TypeScript projects",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"pushpub": "npm run build && npm version patch && git push && npm publish --access public",
|
|
9
|
-
"build": "tsc"
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"watch": "tsc -w",
|
|
11
|
+
"upgrade:all": "yarn upgrade --latest"
|
|
10
12
|
},
|
|
11
13
|
"type": "commonjs",
|
|
12
14
|
"repository": {
|
|
@@ -28,11 +30,11 @@
|
|
|
28
30
|
],
|
|
29
31
|
"dependencies": {},
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
33
|
-
"@typescript-eslint/parser": "^
|
|
34
|
-
"eslint": "^
|
|
35
|
-
"eslint-config-airbnb-base": "^
|
|
33
|
+
"@types/node": "^18.15.0",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
|
35
|
+
"@typescript-eslint/parser": "^5.54.1",
|
|
36
|
+
"eslint": "^8.35.0",
|
|
37
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
36
38
|
"eslint-config-prettier": "^8.3.0",
|
|
37
39
|
"eslint-plugin-import": "^2.22.1",
|
|
38
40
|
"eslint-plugin-prettier": "^4.0.0",
|