@kawalir/extension-node 0.2.0 → 0.4.0
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/CHANGELOG.md +1 -1
- package/Core/Functions/Process/Arguments/ArgumentsFunctions.ts +6 -0
- package/Core/Functions/Process/Arguments/index.ts +1 -0
- package/Core/Functions/Process/Command/CommandFunctions.ts +18 -0
- package/Core/Functions/Process/Command/index.ts +1 -0
- package/Core/Functions/Process/Life/LifeFunctions.ts +23 -0
- package/Core/Functions/Process/Life/index.ts +1 -0
- package/Core/Functions/Process/ProcessFunctions.ts +9 -0
- package/Core/Functions/Process/index.ts +1 -0
- package/Core/Functions/index.ts +1 -0
- package/External/index.ts +1 -0
- package/Global/Classes/GlobalClasses.d.ts +4 -0
- package/Global/Classes/index.ts +4 -0
- package/Global/Methods/Console/Console.d.ts +7 -0
- package/Global/Methods/Console/index.ts +8 -0
- package/Global/Methods/index.ts +1 -0
- package/index.d.ts +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Declare dependency types
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ArgumentsFunctions";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChildProcess } from "@kawalir/extension-node/External";
|
|
2
|
+
|
|
3
|
+
export class CommandFunctions {
|
|
4
|
+
public static pwsh = (request: {
|
|
5
|
+
command: string;
|
|
6
|
+
folderPath: string;
|
|
7
|
+
}): void => {
|
|
8
|
+
const result = ChildProcess.spawnSync(request.command, {
|
|
9
|
+
cwd: request.folderPath,
|
|
10
|
+
shell: "pwsh",
|
|
11
|
+
stdio: "inherit",
|
|
12
|
+
});
|
|
13
|
+
if (result.status === 0) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
process.exit(result.status);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CommandFunctions";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type Action = () => void;
|
|
2
|
+
|
|
3
|
+
class EnsuredAction {
|
|
4
|
+
public hasBeenCalled: boolean = false;
|
|
5
|
+
constructor(public action: Action) {}
|
|
6
|
+
public ensure = () => {
|
|
7
|
+
if (this.hasBeenCalled) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
this.action();
|
|
11
|
+
this.hasBeenCalled = true;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class LifeFunctions {
|
|
16
|
+
public static doBeforeEnd = (action: () => void) => {
|
|
17
|
+
const ea = new EnsuredAction(() => action());
|
|
18
|
+
process.on("SIGINT", () => ea.ensure());
|
|
19
|
+
process.on("SIGTERM", () => ea.ensure());
|
|
20
|
+
process.on("SIGHUP", () => ea.ensure());
|
|
21
|
+
process.on("exit", () => ea.ensure());
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./LifeFunctions";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ArgumentsFunctions } from "./Arguments";
|
|
2
|
+
import { CommandFunctions } from "./Command";
|
|
3
|
+
import { LifeFunctions } from "./Life";
|
|
4
|
+
|
|
5
|
+
export class ProcessFunctions {
|
|
6
|
+
public static arguments = ArgumentsFunctions;
|
|
7
|
+
public static command = CommandFunctions;
|
|
8
|
+
public static life = LifeFunctions;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ProcessFunctions";
|
package/Core/Functions/index.ts
CHANGED
package/External/index.ts
CHANGED
package/Global/Classes/index.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReadLine } from "@kawalir/extension-node/External";
|
|
2
|
+
|
|
3
|
+
console.ReadLine = async (prompt?: string) => {
|
|
4
|
+
const int = ReadLine.createInterface(process.stdin, process.stdout);
|
|
5
|
+
const answer = await int.question(prompt ?? "");
|
|
6
|
+
int.close();
|
|
7
|
+
return answer;
|
|
8
|
+
};
|
package/Global/Methods/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./Console";
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/// <reference path="../extension/index.d.ts" />
|
|
2
|
+
|
|
1
3
|
//? [Global]
|
|
2
4
|
/// <reference path="Global/Classes/GlobalClasses.d.ts" />
|
|
3
|
-
/// <reference path="Global/Modules/GlobalModules.d.ts" />
|
|
5
|
+
/// <reference path="Global/Modules/GlobalModules.d.ts" />
|
|
6
|
+
/// <reference path="Global/Methods/Console/Console.d.ts" />
|