isaacscript 2.0.6 → 2.0.9

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 (142) hide show
  1. package/dist/package.json +12 -6
  2. package/dist/src/commands/init/createMod.js +9 -9
  3. package/dist/src/commands/init/git.js +3 -3
  4. package/dist/src/commands/init/init.js +2 -2
  5. package/dist/src/commands/monitor/monitor.js +9 -9
  6. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +2 -2
  7. package/dist/src/configFile.js +1 -1
  8. package/dist/src/constants.js +12 -9
  9. package/dist/src/file.js +1 -1
  10. package/dist/src/main.js +3 -3
  11. package/dist/src/utils.js +5 -5
  12. package/dist/src/validateInIsaacScriptProject.js +1 -1
  13. package/package.json +12 -6
  14. package/.cspell.json +0 -25
  15. package/.eslintrc.js +0 -28
  16. package/.gitattributes +0 -9
  17. package/.github/workflows/ci.yml +0 -47
  18. package/.prettierignore +0 -5
  19. package/.prettierrc.js +0 -42
  20. package/.vscode/extensions.json +0 -9
  21. package/.vscode/settings.json +0 -75
  22. package/build.sh +0 -30
  23. package/check-file-updates.sh +0 -67
  24. package/check-file-updates.txt +0 -8
  25. package/check-gitignore.sh +0 -26
  26. package/check-orphaned-words.sh +0 -58
  27. package/dist/src/checkForWindowsTerminalBugs.js.map +0 -1
  28. package/dist/src/commands/copy/copy.js.map +0 -1
  29. package/dist/src/commands/init/checkIfProjectPathExists.js.map +0 -1
  30. package/dist/src/commands/init/checkModSubdirectory.js.map +0 -1
  31. package/dist/src/commands/init/checkModTargetDirectory.js.map +0 -1
  32. package/dist/src/commands/init/createMod.js.map +0 -1
  33. package/dist/src/commands/init/getModsDir.js.map +0 -1
  34. package/dist/src/commands/init/getProjectPath.js.map +0 -1
  35. package/dist/src/commands/init/git.js.map +0 -1
  36. package/dist/src/commands/init/init.js.map +0 -1
  37. package/dist/src/commands/init/installVSCodeExtensions.js.map +0 -1
  38. package/dist/src/commands/init/promptSaveSlot.js.map +0 -1
  39. package/dist/src/commands/init/promptVSCode.js.map +0 -1
  40. package/dist/src/commands/monitor/copyWatcherMod.js.map +0 -1
  41. package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +0 -1
  42. package/dist/src/commands/monitor/monitor.js.map +0 -1
  43. package/dist/src/commands/monitor/notifyGame.js.map +0 -1
  44. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +0 -1
  45. package/dist/src/commands/monitor/saveDatWriter/types.js.map +0 -1
  46. package/dist/src/commands/monitor/spawnSaveDatWriter.js.map +0 -1
  47. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js.map +0 -1
  48. package/dist/src/commands/publish/publish.js.map +0 -1
  49. package/dist/src/configFile.js.map +0 -1
  50. package/dist/src/constants.js.map +0 -1
  51. package/dist/src/exec.js.map +0 -1
  52. package/dist/src/file.js.map +0 -1
  53. package/dist/src/main.js.map +0 -1
  54. package/dist/src/parseArgs.js.map +0 -1
  55. package/dist/src/prompt.js.map +0 -1
  56. package/dist/src/types/Command.js.map +0 -1
  57. package/dist/src/types/Config.js.map +0 -1
  58. package/dist/src/types/GitHubCLIHostsYAML.js.map +0 -1
  59. package/dist/src/utils.js.map +0 -1
  60. package/dist/src/validateInIsaacScriptProject.js.map +0 -1
  61. package/dist/src/validateNodeVersion.js.map +0 -1
  62. package/dist/src/validateOS.js.map +0 -1
  63. package/eslint-debug.sh +0 -11
  64. package/file-templates/dynamic/README.md +0 -3
  65. package/file-templates/dynamic/gitignore +0 -144
  66. package/file-templates/dynamic/main.ts +0 -19
  67. package/file-templates/dynamic/metadata.vdf +0 -6
  68. package/file-templates/dynamic/metadata.xml +0 -8
  69. package/file-templates/dynamic/package.json +0 -20
  70. package/file-templates/static/.cspell.json.template +0 -21
  71. package/file-templates/static/.env_template +0 -2
  72. package/file-templates/static/.eslintrc.js +0 -24
  73. package/file-templates/static/.gitattributes +0 -9
  74. package/file-templates/static/.github/workflows/ci.yml +0 -53
  75. package/file-templates/static/.prettierignore +0 -14
  76. package/file-templates/static/.prettierrc.js +0 -42
  77. package/file-templates/static/.vscode/extensions.json +0 -10
  78. package/file-templates/static/.vscode/settings.json +0 -75
  79. package/file-templates/static/LICENSE +0 -674
  80. package/file-templates/static/build.sh +0 -15
  81. package/file-templates/static/check-orphaned-words.sh +0 -58
  82. package/file-templates/static/lint.sh +0 -39
  83. package/file-templates/static/nuke.sh +0 -18
  84. package/file-templates/static/plugins/addCrashDebugStatements.ts +0 -40
  85. package/file-templates/static/plugins/addIsaacScriptCommentHeader.ts +0 -37
  86. package/file-templates/static/plugins/noExtendedEnums.ts +0 -66
  87. package/file-templates/static/publish.sh +0 -10
  88. package/file-templates/static/run.sh +0 -10
  89. package/file-templates/static/src/bundleEntry.ts +0 -10
  90. package/file-templates/static/tsconfig.eslint.json +0 -11
  91. package/file-templates/static/tsconfig.json +0 -33
  92. package/file-templates/static/update.sh +0 -21
  93. package/file-templates/static-alt/.prettierignore-base +0 -5
  94. package/file-templates/static-alt/.prettierrc-base.js +0 -30
  95. package/file-templates/static-alt/.vscode/extensions-format.json +0 -8
  96. package/file-templates/static-alt/.vscode/extensions-typescript.json +0 -9
  97. package/file-templates/static-alt/.vscode/settings-typescript.json +0 -63
  98. package/file-templates/static-alt/check-file-updates.sh +0 -67
  99. package/lint.sh +0 -38
  100. package/misc/logo.png +0 -0
  101. package/misc/mouseover.png +0 -0
  102. package/nuke.sh +0 -18
  103. package/publish.sh +0 -11
  104. package/src/checkForWindowsTerminalBugs.ts +0 -106
  105. package/src/commands/copy/copy.ts +0 -41
  106. package/src/commands/init/checkIfProjectPathExists.ts +0 -34
  107. package/src/commands/init/checkModSubdirectory.ts +0 -20
  108. package/src/commands/init/checkModTargetDirectory.ts +0 -42
  109. package/src/commands/init/createMod.ts +0 -196
  110. package/src/commands/init/getModsDir.ts +0 -107
  111. package/src/commands/init/getProjectPath.ts +0 -111
  112. package/src/commands/init/git.ts +0 -249
  113. package/src/commands/init/init.ts +0 -93
  114. package/src/commands/init/installVSCodeExtensions.ts +0 -47
  115. package/src/commands/init/promptSaveSlot.ts +0 -27
  116. package/src/commands/init/promptVSCode.ts +0 -33
  117. package/src/commands/monitor/copyWatcherMod.ts +0 -54
  118. package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +0 -67
  119. package/src/commands/monitor/monitor.ts +0 -180
  120. package/src/commands/monitor/notifyGame.ts +0 -59
  121. package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +0 -145
  122. package/src/commands/monitor/saveDatWriter/types.ts +0 -6
  123. package/src/commands/monitor/spawnSaveDatWriter.ts +0 -36
  124. package/src/commands/monitor/touchWatcherSaveDatFiles.ts +0 -20
  125. package/src/commands/publish/publish.ts +0 -392
  126. package/src/configFile.ts +0 -80
  127. package/src/constants.ts +0 -85
  128. package/src/exec.ts +0 -125
  129. package/src/file.ts +0 -235
  130. package/src/main.ts +0 -131
  131. package/src/parseArgs.ts +0 -127
  132. package/src/prompt.ts +0 -109
  133. package/src/types/Command.ts +0 -3
  134. package/src/types/Config.ts +0 -23
  135. package/src/types/GitHubCLIHostsYAML.ts +0 -7
  136. package/src/utils.ts +0 -92
  137. package/src/validateInIsaacScriptProject.ts +0 -35
  138. package/src/validateNodeVersion.ts +0 -29
  139. package/src/validateOS.ts +0 -20
  140. package/tsconfig.eslint.json +0 -11
  141. package/tsconfig.json +0 -21
  142. package/update.sh +0 -21
@@ -1,180 +0,0 @@
1
- import chalk from "chalk";
2
- import { fork, spawn } from "child_process";
3
- import * as JSONC from "jsonc-parser";
4
- import path from "path";
5
- import {
6
- CWD,
7
- FILE_SYNCED_MESSAGE,
8
- MAIN_LUA,
9
- MOD_SOURCE_PATH,
10
- PROJECT_NAME,
11
- TSCONFIG_PATH,
12
- } from "../../constants";
13
- import * as file from "../../file";
14
- import { Config } from "../../types/Config";
15
- import { error, getModTargetDirectoryName } from "../../utils";
16
- import { copyWatcherMod } from "./copyWatcherMod";
17
- import * as notifyGame from "./notifyGame";
18
- import { spawnSaveDatWriter } from "./spawnSaveDatWriter";
19
- import { touchWatcherSaveDatFiles } from "./touchWatcherSaveDatFiles";
20
-
21
- export function monitor(argv: Record<string, unknown>, config: Config): void {
22
- const verbose = argv["verbose"] === true;
23
-
24
- // If they specified some command-line flags, override the values found in the config file
25
- if (argv["modsDirectory"] !== undefined) {
26
- config.modsDirectory = argv["modsDirectory"] as string; // eslint-disable-line no-param-reassign
27
- }
28
- if (argv["saveSlot"] !== undefined) {
29
- config.saveSlot = argv["saveSlot"] as number; // eslint-disable-line no-param-reassign
30
- }
31
-
32
- // Read the "tsconfig.json" file
33
- const tsConfigInclude = getFirstTSConfigIncludePath(verbose);
34
- const resolvedIncludePath = path.resolve(CWD, tsConfigInclude);
35
- const modTargetDirectoryName = getModTargetDirectoryName(config);
36
- const modTargetPath = path.join(config.modsDirectory, modTargetDirectoryName);
37
-
38
- // Prepare the IsaacScript watcher mod
39
- copyWatcherMod(config, verbose);
40
- touchWatcherSaveDatFiles(config, verbose);
41
-
42
- // Delete and re-copy the mod every time IsaacScript starts. This ensures that it is always the
43
- // latest version.
44
- if (file.exists(modTargetPath, verbose)) {
45
- file.deleteFileOrDirectory(modTargetPath, true);
46
- }
47
-
48
- // Subprocess #1 - The "save#.dat" file writer
49
- spawnSaveDatWriter(config);
50
-
51
- // Subprocess #2 - The mod directory syncer
52
- spawnModDirectorySyncer(config);
53
-
54
- // Subprocess #3 - tstl --watch (to automatically convert TypeScript to Lua)
55
- spawnTSTLWatcher();
56
-
57
- // Also, start constantly pinging the watcher mod
58
- setInterval(() => {
59
- notifyGame.ping();
60
- }, 1000); // Every second
61
-
62
- console.log("Automatically monitoring the following for changes:");
63
- console.log(
64
- `1) your TypeScript code: ${chalk.green(resolvedIncludePath)}`,
65
- );
66
- console.log(`2) the source mod directory: ${chalk.green(MOD_SOURCE_PATH)}`);
67
- console.log("");
68
- console.log(`Copying files to: ${chalk.green(modTargetPath)}`);
69
- console.log("");
70
- // (the process will now continue indefinitely for as long as the subprocesses exist)
71
- }
72
-
73
- function spawnModDirectorySyncer(config: Config) {
74
- const processName = "modDirectorySyncer";
75
- const processDescription = "Directory syncer";
76
- const processPath = path.join(__dirname, processName, processName);
77
- const modTargetName = getModTargetDirectoryName(config);
78
- const modTargetPath = path.join(config.modsDirectory, modTargetName);
79
- const directorySyncer = fork(processPath, [MOD_SOURCE_PATH, modTargetPath]);
80
-
81
- directorySyncer.on("message", (msg: string) => {
82
- notifyGame.msg(msg);
83
-
84
- // If the "main.lua" file was successfully copied over, we also have to tell isaacscript-watcher
85
- // to reload the mod. Look for something like: "File synced: \main.lua"
86
- if (msg === `${FILE_SYNCED_MESSAGE} ${path.sep}${MAIN_LUA}`) {
87
- notifyGame.command(`luamod ${modTargetName}`);
88
- notifyGame.command("restart");
89
- notifyGame.msg("Reloaded the mod.");
90
- }
91
- });
92
-
93
- directorySyncer.on("close", (code: number | null) => {
94
- error(`Error: ${processDescription} subprocess closed with code: ${code}`);
95
- });
96
-
97
- directorySyncer.on("exit", (code: number | null) => {
98
- error(`Error: ${processDescription} subprocess exited with code: ${code}`);
99
- });
100
- }
101
-
102
- function spawnTSTLWatcher() {
103
- const processDescription = "tstl";
104
- const tstl = spawn("npx", ["tstl", "--watch", "--preserveWatchOutput"], {
105
- shell: true,
106
- });
107
-
108
- tstl.stdout.on("data", (data: Buffer[]) => {
109
- const msg = data.toString().trim();
110
- if (msg.includes("Starting compilation in watch mode...")) {
111
- const newMsg = `${PROJECT_NAME} is now watching for changes.`;
112
- notifyGame.msg(newMsg);
113
- } else if (
114
- msg.includes("File change detected. Starting incremental compilation...")
115
- ) {
116
- const newMsg = "TypeScript change detected. Compiling...";
117
- notifyGame.msg(newMsg);
118
- } else if (msg.includes("Found 0 errors. Watching for file changes.")) {
119
- const newMsg = "Compilation successful.";
120
- notifyGame.msg(newMsg);
121
- } else {
122
- notifyGame.msg(msg);
123
- }
124
- });
125
-
126
- tstl.stderr.on("data", (data: Buffer[]) => {
127
- const msg = data.toString().trim();
128
- if (msg === "^C") {
129
- // Hide the line that appears when you cancel the program with Ctrl + c
130
- return;
131
- }
132
- notifyGame.msg(`Error: ${msg}`);
133
- });
134
-
135
- tstl.on("close", (code) => {
136
- error(`Error: ${processDescription} subprocess exited with code: ${code}`);
137
- });
138
-
139
- tstl.on("exit", (code) => {
140
- error(`Error: ${processDescription} subprocess exited with code: ${code}`);
141
- });
142
- }
143
-
144
- function getFirstTSConfigIncludePath(verbose: boolean): string {
145
- const tsConfigRaw = file.read(TSCONFIG_PATH, verbose);
146
- let tsConfig: Record<string, string[]>;
147
- try {
148
- tsConfig = JSONC.parse(tsConfigRaw) as Record<string, string[]>;
149
- } catch (err) {
150
- error(`Failed to parse "${chalk.green(TSCONFIG_PATH)}":`, err);
151
- }
152
-
153
- const include = tsConfig["include"];
154
- if (include === undefined) {
155
- error(
156
- `Your "${chalk.green(
157
- TSCONFIG_PATH,
158
- )}" file does not have an "include" property, which is surely a mistake. Delete the file and re-run ${PROJECT_NAME}.`,
159
- );
160
- }
161
-
162
- if (!Array.isArray(include)) {
163
- error(
164
- `Your "${chalk.green(
165
- TSCONFIG_PATH,
166
- )}" file has an "include" property that is not an array, which is surely a mistake. Delete the file and re-run ${PROJECT_NAME}.`,
167
- );
168
- }
169
-
170
- const firstInclude = include[0];
171
- if (firstInclude === undefined) {
172
- error(
173
- `Your "${chalk.green(
174
- TSCONFIG_PATH,
175
- )}" file has an empty "include" property, which is surely a mistake. Delete the file and re-run ${PROJECT_NAME}.`,
176
- );
177
- }
178
-
179
- return firstInclude;
180
- }
@@ -1,59 +0,0 @@
1
- import chalk from "chalk";
2
- import { getTime } from "../../utils";
3
- import { sendMsgToSaveDatWriter } from "./spawnSaveDatWriter";
4
-
5
- export function msg(data: string): void {
6
- const formattedData = data
7
- .replace(/\r\n/g, "\n") // Replace Windows newlines with Unix newlines
8
- .trim(); // Trim whitespace
9
-
10
- for (const line of formattedData.split("\n")) {
11
- const trimmedLine = line.trim();
12
- if (trimmedLine === "") {
13
- continue;
14
- }
15
-
16
- // Ignore the final message from tstl upon exiting the program.
17
- if (trimmedLine === "Terminate batch job (Y/N)?") {
18
- return;
19
- }
20
-
21
- // Add a time prefix.
22
- const formattedLine = `[${getTime()}] ${trimmedLine}`;
23
-
24
- sendMsgToSaveDatWriter({
25
- type: "msg",
26
- data: formattedLine,
27
- });
28
-
29
- // We also print the message to standard out so that the end-user can choose between reading
30
- // tstl errors from the IsaacScript terminal window or from looking at the in-game output.
31
- printMsgToStandardOut(formattedLine);
32
- }
33
- }
34
-
35
- function printMsgToStandardOut(data: string) {
36
- let coloredData = data;
37
-
38
- if (data.match(/Compilation successful./g) !== null) {
39
- coloredData = chalk.green(data);
40
- } else if (data.match(/error/g) !== null) {
41
- coloredData = chalk.red(data);
42
- }
43
-
44
- console.log(coloredData);
45
- }
46
-
47
- export function command(data: string): void {
48
- sendMsgToSaveDatWriter({
49
- type: "command",
50
- data,
51
- });
52
- }
53
-
54
- export function ping(): void {
55
- sendMsgToSaveDatWriter({
56
- type: "ping",
57
- data: "",
58
- });
59
- }
@@ -1,145 +0,0 @@
1
- import * as JSONC from "jsonc-parser";
2
- import path from "path";
3
- import { PROJECT_NAME } from "../../../constants";
4
- import * as file from "../../../file";
5
- import { ensureAllCases } from "../../../utils";
6
- import { SaveDatMessage, SaveDatMessageType } from "./types";
7
-
8
- const SUBPROCESS_NAME = "save#.dat writer";
9
- const BASE_ARGV_LENGTH = 2;
10
- const MAX_MESSAGES = 100;
11
- const VERBOSE = false;
12
-
13
- let saveDatPath: string;
14
- let saveDatFileName: string;
15
-
16
- init(VERBOSE);
17
-
18
- function init(verbose: boolean) {
19
- const firstArg = process.argv[BASE_ARGV_LENGTH];
20
- if (firstArg === undefined) {
21
- throw new Error(
22
- `The ${SUBPROCESS_NAME} process did not get a valid first argument.`,
23
- );
24
- }
25
-
26
- saveDatPath = firstArg;
27
- saveDatFileName = path.basename(saveDatPath);
28
-
29
- // Check to see if the data directory exists
30
- const watcherModDataPath = path.dirname(saveDatPath);
31
- if (!file.exists(watcherModDataPath, verbose)) {
32
- file.makeDir(watcherModDataPath, verbose);
33
- }
34
-
35
- // Listen for messages from the parent process
36
- process.on("message", (msg: SaveDatMessage) => {
37
- onMessage(msg.type, msg.data);
38
- });
39
- }
40
-
41
- function onMessage(type: SaveDatMessageType, data: string, numRetries = 0) {
42
- const saveDat = readSaveDatFromDisk(VERBOSE);
43
- if (saveDat.length > MAX_MESSAGES) {
44
- // If IsaacScript is running and:
45
- // - the game is not open
46
- // - or the game is open but the IsaacScript Watcher mod is disabled
47
- //
48
- // Then this process will continue to write to the "save#.dat" file, which can cause it to grow
49
- // arbitrarily large (since there is no-one on the other side removing the messages). If there
50
- // is N messages already in the queue, assume that no-one is listening and stop adding any more
51
- // messages.
52
- return;
53
- }
54
- addMessageToSaveDat(type, saveDat, data); // Mutates saveDat
55
- writeSaveDatToDisk(type, data, saveDat, numRetries, VERBOSE);
56
- }
57
-
58
- function readSaveDatFromDisk(verbose: boolean) {
59
- let saveDat: SaveDatMessage[];
60
- if (file.exists(saveDatPath, verbose)) {
61
- const saveDatRaw = file.read(saveDatPath, verbose);
62
- try {
63
- saveDat = JSONC.parse(saveDatRaw) as SaveDatMessage[];
64
- } catch (err) {
65
- send(`Failed to parse "${saveDatPath}": ${err}`);
66
- process.exit(1);
67
- }
68
- } else {
69
- saveDat = [];
70
- }
71
- if (!Array.isArray(saveDat)) {
72
- saveDat = [];
73
- }
74
-
75
- return saveDat;
76
- }
77
-
78
- function addMessageToSaveDat(
79
- type: SaveDatMessageType,
80
- saveDat: SaveDatMessage[],
81
- data: string,
82
- ) {
83
- switch (type) {
84
- case "command":
85
- case "ping": {
86
- saveDat.push({
87
- type,
88
- data,
89
- });
90
-
91
- break;
92
- }
93
-
94
- case "msg": {
95
- const lines = data.split("\n");
96
- for (const line of lines) {
97
- saveDat.push({
98
- type,
99
- data: line,
100
- });
101
- }
102
-
103
- break;
104
- }
105
-
106
- default: {
107
- ensureAllCases(type);
108
- break;
109
- }
110
- }
111
- }
112
-
113
- function writeSaveDatToDisk(
114
- type: SaveDatMessageType,
115
- data: string,
116
- saveDat: SaveDatMessage[],
117
- numRetries: number,
118
- verbose: boolean,
119
- ) {
120
- const saveDatRaw = JSON.stringify(saveDat, null, 2);
121
- try {
122
- file.writeTry(saveDatPath, saveDatRaw, verbose);
123
- } catch (err) {
124
- if (numRetries > 4) {
125
- send(
126
- `Failed to write to the ${saveDatFileName} for 5 times in a row. Maybe the file got locked somehow. ${PROJECT_NAME} will now exit.`,
127
- );
128
- send(`The writing error is as follows: ${err}`);
129
- process.exit(1);
130
- }
131
-
132
- send(
133
- `Writing to "${saveDatFileName}" failed. (The number of retries so far is ${numRetries}.) Trying again in 0.1 seconds...`,
134
- );
135
- setTimeout(() => {
136
- onMessage(type, data, numRetries + 1);
137
- }, 100);
138
- }
139
- }
140
-
141
- function send(msg: string) {
142
- if (process.send !== undefined) {
143
- process.send(msg);
144
- }
145
- }
@@ -1,6 +0,0 @@
1
- export type SaveDatMessageType = "command" | "msg" | "ping";
2
-
3
- export interface SaveDatMessage {
4
- type: SaveDatMessageType;
5
- data: string;
6
- }
@@ -1,36 +0,0 @@
1
- import { ChildProcess, fork } from "child_process";
2
- import path from "path";
3
- import { WATCHER_MOD_NAME } from "../../constants";
4
- import { Config } from "../../types/Config";
5
- import { error } from "../../utils";
6
- import { SaveDatMessage } from "./saveDatWriter/types";
7
-
8
- let saveDatWriter: ChildProcess | null = null;
9
-
10
- export function spawnSaveDatWriter(config: Config): void {
11
- const processName = "saveDatWriter";
12
- const processDescription = "save#.dat writer";
13
- const processPath = path.join(__dirname, processName, processName);
14
- const modsDataPath = path.join(config.modsDirectory, "..", "data");
15
- const watcherModDataPath = path.join(modsDataPath, WATCHER_MOD_NAME);
16
- const saveDatFileName = `save${config.saveSlot}.dat`;
17
- const saveDatPath = path.join(watcherModDataPath, saveDatFileName);
18
-
19
- saveDatWriter = fork(processPath, [saveDatPath], {
20
- stdio: ["pipe", "pipe", "pipe", "ipc"],
21
- });
22
-
23
- saveDatWriter.on("close", (code: number | null) => {
24
- error(`Error: ${processDescription} subprocess closed with code: ${code}`);
25
- });
26
-
27
- saveDatWriter.on("exit", (code: number | null) => {
28
- error(`Error: ${processDescription} subprocess exited with code: ${code}`);
29
- });
30
- }
31
-
32
- export function sendMsgToSaveDatWriter(msg: SaveDatMessage): void {
33
- if (saveDatWriter !== null) {
34
- saveDatWriter.send(msg);
35
- }
36
- }
@@ -1,20 +0,0 @@
1
- import path from "path";
2
- import { WATCHER_MOD_NAME } from "../../constants";
3
- import * as file from "../../file";
4
- import { Config } from "../../types/Config";
5
-
6
- export function touchWatcherSaveDatFiles(
7
- config: Config,
8
- verbose: boolean,
9
- ): void {
10
- const modsDataPath = path.join(config.modsDirectory, "..", "data");
11
- const watcherModDataPath = path.join(modsDataPath, WATCHER_MOD_NAME);
12
- if (!file.exists(watcherModDataPath, verbose)) {
13
- file.makeDir(watcherModDataPath, verbose);
14
- }
15
- const saveDatFileName = `save${config.saveSlot}.dat`;
16
- const saveDatPath = path.join(watcherModDataPath, saveDatFileName);
17
- if (!file.exists(saveDatPath, verbose)) {
18
- file.touch(saveDatPath, verbose);
19
- }
20
- }