isaacscript 1.2.29 → 1.2.32

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 (74) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/checkForWindowsTerminalBugs.js +7 -7
  3. package/dist/src/checkForWindowsTerminalBugs.js.map +1 -1
  4. package/dist/src/commands/copy/copy.js +1 -1
  5. package/dist/src/commands/copy/copy.js.map +1 -1
  6. package/dist/src/commands/init/checkIfProjectPathExists.js +2 -2
  7. package/dist/src/commands/init/checkIfProjectPathExists.js.map +1 -1
  8. package/dist/src/commands/init/checkModTargetDirectory.js +2 -2
  9. package/dist/src/commands/init/checkModTargetDirectory.js.map +1 -1
  10. package/dist/src/commands/init/createMod.js +8 -8
  11. package/dist/src/commands/init/createMod.js.map +1 -1
  12. package/dist/src/commands/init/getModsDir.js +5 -4
  13. package/dist/src/commands/init/getModsDir.js.map +1 -1
  14. package/dist/src/commands/init/getProjectPath.js +7 -10
  15. package/dist/src/commands/init/getProjectPath.js.map +1 -1
  16. package/dist/src/commands/init/git.js +6 -6
  17. package/dist/src/commands/init/git.js.map +1 -1
  18. package/dist/src/commands/init/init.js +1 -1
  19. package/dist/src/commands/init/init.js.map +1 -1
  20. package/dist/src/commands/init/installVSCodeExtensions.js +4 -4
  21. package/dist/src/commands/init/installVSCodeExtensions.js.map +1 -1
  22. package/dist/src/commands/monitor/copyWatcherMod.js +3 -3
  23. package/dist/src/commands/monitor/copyWatcherMod.js.map +1 -1
  24. package/dist/src/commands/monitor/getTSConfigInclude.js +2 -2
  25. package/dist/src/commands/monitor/getTSConfigInclude.js.map +1 -1
  26. package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +2 -2
  27. package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +1 -1
  28. package/dist/src/commands/monitor/monitor.js +2 -2
  29. package/dist/src/commands/monitor/monitor.js.map +1 -1
  30. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js +24 -18
  31. package/dist/src/commands/monitor/saveDatWriter/saveDatWriter.js.map +1 -1
  32. package/dist/src/commands/monitor/spawnSaveDatWriter.js +1 -1
  33. package/dist/src/commands/monitor/spawnSaveDatWriter.js.map +1 -1
  34. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js +2 -2
  35. package/dist/src/commands/monitor/touchWatcherSaveDatFiles.js.map +1 -1
  36. package/dist/src/commands/publish/publish.js +16 -16
  37. package/dist/src/commands/publish/publish.js.map +1 -1
  38. package/dist/src/configFile.js +5 -5
  39. package/dist/src/configFile.js.map +1 -1
  40. package/dist/src/exec.js +2 -2
  41. package/dist/src/exec.js.map +1 -1
  42. package/dist/src/file.js +37 -7
  43. package/dist/src/file.js.map +1 -1
  44. package/dist/src/main.js +5 -4
  45. package/dist/src/main.js.map +1 -1
  46. package/dist/src/utils.js +7 -1
  47. package/dist/src/utils.js.map +1 -1
  48. package/dist/src/validateInIsaacScriptProject.js +3 -2
  49. package/dist/src/validateInIsaacScriptProject.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/checkForWindowsTerminalBugs.ts +9 -7
  52. package/src/commands/copy/copy.ts +1 -1
  53. package/src/commands/init/checkIfProjectPathExists.ts +2 -2
  54. package/src/commands/init/checkModTargetDirectory.ts +2 -2
  55. package/src/commands/init/createMod.ts +8 -8
  56. package/src/commands/init/getModsDir.ts +7 -3
  57. package/src/commands/init/getProjectPath.ts +10 -11
  58. package/src/commands/init/git.ts +6 -6
  59. package/src/commands/init/init.ts +1 -1
  60. package/src/commands/init/installVSCodeExtensions.ts +4 -4
  61. package/src/commands/monitor/copyWatcherMod.ts +3 -3
  62. package/src/commands/monitor/getTSConfigInclude.ts +2 -2
  63. package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +2 -2
  64. package/src/commands/monitor/monitor.ts +2 -2
  65. package/src/commands/monitor/saveDatWriter/saveDatWriter.ts +28 -20
  66. package/src/commands/monitor/spawnSaveDatWriter.ts +1 -1
  67. package/src/commands/monitor/touchWatcherSaveDatFiles.ts +2 -2
  68. package/src/commands/publish/publish.ts +16 -16
  69. package/src/configFile.ts +5 -5
  70. package/src/exec.ts +2 -4
  71. package/src/file.ts +51 -7
  72. package/src/main.ts +5 -4
  73. package/src/utils.ts +8 -0
  74. package/src/validateInIsaacScriptProject.ts +5 -2
@@ -1 +1 @@
1
- {"version":3,"file":"validateInIsaacScriptProject.js","sourceRoot":"","sources":["../../src/validateInIsaacScriptProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,gDAAwB;AACxB,2CAAgD;AAChD,6CAA+B;AAE/B,6EAA6E;AAC7E,SAAgB,4BAA4B;IAC1C,MAAM,qBAAqB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAC7D,KAAK,MAAM,gBAAgB,IAAI,qBAAqB,EAAE;QACpD,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,eAAG,EAAE,gBAAgB,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE;YACnE,cAAc,CAAC,gBAAgB,CAAC,CAAC;SAClC;KACF;AACH,CAAC;AARD,oEAQC;AAED,SAAS,cAAc,CAAC,OAAe;IACrC,OAAO,CAAC,KAAK,CACX,eAAK,CAAC,GAAG,CACP,yDAAyD,wBAAY,2BAA2B,OAAO,uBAAuB,CAC/H,CACF,CAAC;IACF,OAAO,CAAC,KAAK,CACX,gCAAgC,wBAAY,kBAAkB,eAAK,CAAC,KAAK,CACvE,sBAAsB,CACvB,IAAI,CACN,CAAC;IACF,OAAO,CAAC,KAAK,CACX,2DAA2D,wBAAY,WAAW,CACnF,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"validateInIsaacScriptProject.js","sourceRoot":"","sources":["../../src/validateInIsaacScriptProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,gDAAwB;AACxB,2CAAgD;AAChD,6CAA+B;AAE/B,6EAA6E;AAC7E,SAAgB,4BAA4B,CAAC,OAAgB;IAC3D,MAAM,qBAAqB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAC7D,KAAK,MAAM,gBAAgB,IAAI,qBAAqB,EAAE;QACpD,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,eAAG,EAAE,gBAAgB,CAAC,CAAC;QAC1D,IACE,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,OAAO,CAAC;YACvC,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAO,CAAC,EACtC;YACA,cAAc,CAAC,gBAAgB,CAAC,CAAC;SAClC;KACF;AACH,CAAC;AAXD,oEAWC;AAED,SAAS,cAAc,CAAC,OAAe;IACrC,OAAO,CAAC,KAAK,CACX,eAAK,CAAC,GAAG,CACP,yDAAyD,wBAAY,2BAA2B,OAAO,uBAAuB,CAC/H,CACF,CAAC;IACF,OAAO,CAAC,KAAK,CACX,gCAAgC,wBAAY,kBAAkB,eAAK,CAAC,KAAK,CACvE,sBAAsB,CACvB,IAAI,CACN,CAAC;IACF,OAAO,CAAC,KAAK,CACX,2DAA2D,wBAAY,WAAW,CACnF,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript",
3
- "version": "1.2.29",
3
+ "version": "1.2.32",
4
4
  "description": "A command line tool for managing Isaac mods written in TypeScript",
5
5
  "homepage": "https://isaacscript.github.io/",
6
6
  "bugs": {
@@ -45,6 +45,6 @@
45
45
  "@types/source-map-support": "^0.5.4",
46
46
  "@types/update-notifier": "^5.1.0",
47
47
  "@types/yargs": "^17.0.10",
48
- "isaacscript-lint": "^1.0.95"
48
+ "isaacscript-lint": "^1.0.99"
49
49
  }
50
50
  }
@@ -11,7 +11,9 @@ const BASH_PROFILE_PATH = path.join(HOME_DIR, ".bash_profile");
11
11
  // By default, Git Bash for Windows uses MINGW64
12
12
  // This will not work correctly with the prompt library
13
13
  // Try to detect this and warn the end-user
14
- export async function checkForWindowsTerminalBugs(): Promise<void> {
14
+ export async function checkForWindowsTerminalBugs(
15
+ verbose: boolean,
16
+ ): Promise<void> {
15
17
  if (process.platform !== "win32") {
16
18
  return;
17
19
  }
@@ -20,10 +22,10 @@ export async function checkForWindowsTerminalBugs(): Promise<void> {
20
22
  return;
21
23
  }
22
24
 
23
- await checkForWindowsBugColor();
25
+ await checkForWindowsBugColor(verbose);
24
26
  }
25
27
 
26
- async function checkForWindowsBugColor() {
28
+ async function checkForWindowsBugColor(verbose: boolean) {
27
29
  if (process.env.FORCE_COLOR === "true") {
28
30
  return;
29
31
  }
@@ -46,14 +48,14 @@ async function checkForWindowsBugColor() {
46
48
  return;
47
49
  }
48
50
 
49
- applyFixesToBashProfile();
51
+ applyFixesToBashProfile(verbose);
50
52
  }
51
53
 
52
- function applyFixesToBashProfile() {
54
+ function applyFixesToBashProfile(verbose: boolean) {
53
55
  // Check to see if the Bash profile has data
54
56
  let bashProfileContents: string;
55
- if (file.exists(BASH_PROFILE_PATH)) {
56
- bashProfileContents = file.read(BASH_PROFILE_PATH);
57
+ if (file.exists(BASH_PROFILE_PATH, verbose)) {
58
+ bashProfileContents = file.read(BASH_PROFILE_PATH, verbose);
57
59
  } else {
58
60
  bashProfileContents = "";
59
61
  }
@@ -33,7 +33,7 @@ function copyMod(
33
33
  modTargetPath: string,
34
34
  verbose: boolean,
35
35
  ) {
36
- if (file.exists(modTargetPath)) {
36
+ if (file.exists(modTargetPath, verbose)) {
37
37
  file.deleteFileOrDirectory(modTargetPath, verbose);
38
38
  }
39
39
  file.copy(modSourcePath, modTargetPath, verbose);
@@ -9,11 +9,11 @@ export async function checkIfProjectPathExists(
9
9
  yes: boolean,
10
10
  verbose: boolean,
11
11
  ): Promise<void> {
12
- if (projectPath === CWD || !file.exists(projectPath)) {
12
+ if (projectPath === CWD || !file.exists(projectPath, verbose)) {
13
13
  return;
14
14
  }
15
15
 
16
- const fileType = file.isDir(projectPath) ? "directory" : "file";
16
+ const fileType = file.isDir(projectPath, verbose) ? "directory" : "file";
17
17
 
18
18
  if (yes) {
19
19
  file.deleteFileOrDirectory(projectPath, verbose);
@@ -12,11 +12,11 @@ export async function checkModTargetDirectory(
12
12
  verbose: boolean,
13
13
  ): Promise<void> {
14
14
  const modTargetPath = path.join(modsDirectory, projectName);
15
- if (!file.exists(modTargetPath)) {
15
+ if (!file.exists(modTargetPath, verbose)) {
16
16
  return;
17
17
  }
18
18
 
19
- const fileType = file.isDir(modTargetPath) ? "directory" : "file";
19
+ const fileType = file.isDir(modTargetPath, verbose) ? "directory" : "file";
20
20
 
21
21
  if (yes) {
22
22
  file.deleteFileOrDirectory(modTargetPath, verbose);
@@ -61,11 +61,11 @@ function makeSubdirectories(projectPath: string, verbose: boolean) {
61
61
 
62
62
  /** Copy static files, like ".eslintrc.js", "tsconfig.json", etc. */
63
63
  function copyStaticFiles(projectPath: string, verbose: boolean) {
64
- const staticFileList = file.getDirList(TEMPLATES_STATIC_DIR);
64
+ const staticFileList = file.getDirList(TEMPLATES_STATIC_DIR, verbose);
65
65
  staticFileList.forEach((fileName: string) => {
66
66
  const templateFilePath = path.join(TEMPLATES_STATIC_DIR, fileName);
67
67
  const destinationFilePath = path.join(projectPath, fileName);
68
- if (!file.exists(destinationFilePath)) {
68
+ if (!file.exists(destinationFilePath, verbose)) {
69
69
  file.copy(templateFilePath, destinationFilePath, verbose);
70
70
  }
71
71
  });
@@ -82,7 +82,7 @@ function copyDynamicFiles(
82
82
  {
83
83
  const fileName = GITIGNORE;
84
84
  const templatePath = GITIGNORE_TEMPLATE_PATH;
85
- const template = file.read(templatePath);
85
+ const template = file.read(templatePath, verbose);
86
86
 
87
87
  // Prepend a header with the project name
88
88
  let separatorLine = "# ";
@@ -102,7 +102,7 @@ function copyDynamicFiles(
102
102
  // Modify and copy the file
103
103
  const fileName = PACKAGE_JSON;
104
104
  const templatePath = PACKAGE_JSON_TEMPLATE_PATH;
105
- const template = file.read(templatePath);
105
+ const template = file.read(templatePath, verbose);
106
106
  const packageJSON = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
107
107
  const destinationPath = path.join(projectPath, fileName);
108
108
  file.write(destinationPath, packageJSON, verbose);
@@ -112,7 +112,7 @@ function copyDynamicFiles(
112
112
  {
113
113
  const fileName = README_MD;
114
114
  const templatePath = README_MD_TEMPLATES_PATH;
115
- const template = file.read(templatePath);
115
+ const template = file.read(templatePath, verbose);
116
116
  const readmeMD = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
117
117
  const destinationPath = path.join(projectPath, fileName);
118
118
  file.write(destinationPath, readmeMD, verbose);
@@ -122,7 +122,7 @@ function copyDynamicFiles(
122
122
  {
123
123
  const fileName = METADATA_XML;
124
124
  const templatePath = METADATA_XML_TEMPLATE_PATH;
125
- const template = file.read(templatePath);
125
+ const template = file.read(templatePath, verbose);
126
126
  const metadataXML = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
127
127
  const modPath = path.join(projectPath, "mod");
128
128
  const destinationPath = path.join(modPath, fileName);
@@ -133,7 +133,7 @@ function copyDynamicFiles(
133
133
  {
134
134
  const fileName = METADATA_VDF;
135
135
  const templatePath = METADATA_VDF_TEMPLATE_PATH;
136
- const template = file.read(templatePath);
136
+ const template = file.read(templatePath, verbose);
137
137
  const metadataVDF = template.replace(/MOD_TARGET_DIR/g, targetModDirectory);
138
138
  const modPath = path.join(projectPath, "mod");
139
139
  const destinationPath = path.join(modPath, fileName);
@@ -147,7 +147,7 @@ function copyDynamicFiles(
147
147
  const srcPath = path.join(projectPath, "src");
148
148
  const fileName = MAIN_TS;
149
149
  const templatePath = MAIN_TS_TEMPLATE_PATH;
150
- const template = file.read(templatePath);
150
+ const template = file.read(templatePath, verbose);
151
151
  const mainTS = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
152
152
  const destinationPath = path.join(srcPath, fileName);
153
153
  file.write(destinationPath, mainTS, verbose);
@@ -31,6 +31,7 @@ const DEFAULT_MODS_PATH_LINUX = path.join(
31
31
 
32
32
  export async function getModsDir(
33
33
  argv: Record<string, unknown>,
34
+ verbose: boolean,
34
35
  ): Promise<string> {
35
36
  if (argv.modsDirectory !== undefined) {
36
37
  // They specified the "--mods-directory" command-line flag,
@@ -40,7 +41,10 @@ export async function getModsDir(
40
41
 
41
42
  const defaultModsPath = getDefaultModsPath(process.platform);
42
43
 
43
- if (file.exists(defaultModsPath) && file.isDir(defaultModsPath)) {
44
+ if (
45
+ file.exists(defaultModsPath, verbose) &&
46
+ file.isDir(defaultModsPath, verbose)
47
+ ) {
44
48
  return defaultModsPath;
45
49
  }
46
50
 
@@ -55,7 +59,7 @@ export async function getModsDir(
55
59
  error("Error: You did not provide a response; exiting.");
56
60
  }
57
61
 
58
- if (!file.exists(modsDir)) {
62
+ if (!file.exists(modsDir, verbose)) {
59
63
  error(
60
64
  `Error: The directory of "${chalk.green(
61
65
  modsDir,
@@ -63,7 +67,7 @@ export async function getModsDir(
63
67
  );
64
68
  }
65
69
 
66
- if (!file.isDir(modsDir)) {
70
+ if (!file.isDir(modsDir, verbose)) {
67
71
  error(
68
72
  `Error: The path of "${chalk.green(
69
73
  modsDir,
@@ -2,7 +2,7 @@ import chalk from "chalk";
2
2
  import path from "path";
3
3
  import { CURRENT_DIRECTORY_NAME, CWD } from "../../constants";
4
4
  import { getInputString, getInputYesNo } from "../../prompt";
5
- import { hasWhiteSpace } from "../../utils";
5
+ import { error, hasWhiteSpace, isKebabCase } from "../../utils";
6
6
 
7
7
  // From: https://gist.github.com/doctaphred/d01d05291546186941e1b7ddc02034d3
8
8
  const ILLEGAL_CHARACTERS_FOR_WINDOWS_FILENAMES = [
@@ -46,9 +46,7 @@ export async function getProjectPath(
46
46
  [projectName, projectPath, createNewDir] = await getNewProjectName();
47
47
  }
48
48
 
49
- if (!validateProjectName(projectName)) {
50
- process.exit(1);
51
- }
49
+ validateProjectName(projectName);
52
50
 
53
51
  console.log(`Using a project name of: ${chalk.green(projectName)}`);
54
52
  return [projectPath, createNewDir];
@@ -82,27 +80,28 @@ async function getNewProjectName(): Promise<[string, string, boolean]> {
82
80
 
83
81
  function validateProjectName(projectName: string) {
84
82
  if (projectName === "") {
85
- console.error("Error: You cannot have a blank project name.");
86
- return false;
83
+ error("Error: You cannot have a blank project name.");
87
84
  }
88
85
 
89
86
  if (process.platform === "win32") {
90
87
  for (const character of ILLEGAL_CHARACTERS_FOR_WINDOWS_FILENAMES) {
91
88
  if (projectName.includes(character)) {
92
- console.error(
89
+ error(
93
90
  `Error: The "${character}" character is not allowed in a Windows file name.`,
94
91
  );
95
- return false;
96
92
  }
97
93
  }
98
94
  }
99
95
 
100
96
  if (hasWhiteSpace(projectName)) {
101
- console.error(
97
+ error(
102
98
  'Error: The project name has whitespace in it, which is not allowed. Use kebab-case for your project name. (e.g. "green-candle")',
103
99
  );
104
- return false;
105
100
  }
106
101
 
107
- return true;
102
+ if (!isKebabCase(projectName)) {
103
+ error(
104
+ "Error: The project name is not in kebab-case. (Kebab-case is the style of using all lowercase letters, with words separated by hyphens.) Project names must use kebab-case to match GitHub repository standards.",
105
+ );
106
+ }
108
107
  }
@@ -27,7 +27,7 @@ export async function promptGitHubRepoOrGitRemoteURL(
27
27
 
28
28
  validateNewGitVersion(verbose);
29
29
 
30
- const gitHubUsername = getGitHubUsername();
30
+ const gitHubUsername = getGitHubUsername(verbose);
31
31
  if (gitHubUsername !== undefined) {
32
32
  const [exitStatus] = execShell(
33
33
  "gh",
@@ -67,7 +67,7 @@ export async function promptGitHubRepoOrGitRemoteURL(
67
67
 
68
68
  if (yes) {
69
69
  execShell("gh", ["repo", "create", projectName, "--public"]);
70
- console.log(`Created a new GitHub repository at: ${url}`);
70
+ console.log(`Created a new GitHub repository at: ${chalk.green(url)}`);
71
71
  return getGitRemoteURL(projectName, gitHubUsername);
72
72
  }
73
73
 
@@ -131,7 +131,7 @@ function validateNewGitVersion(verbose: boolean) {
131
131
  process.exit(1);
132
132
  }
133
133
 
134
- function getGitHubUsername() {
134
+ function getGitHubUsername(verbose: boolean) {
135
135
  // If the GitHub CLI is installed, we can derive the user's GitHub username
136
136
  if (
137
137
  !commandExists.sync("gh") ||
@@ -146,11 +146,11 @@ function getGitHubUsername() {
146
146
  "GitHub CLI",
147
147
  "hosts.yml",
148
148
  );
149
- if (!file.exists(githubCLIHostsPath)) {
149
+ if (!file.exists(githubCLIHostsPath, verbose)) {
150
150
  return undefined;
151
151
  }
152
152
 
153
- const configYAMLRaw = file.read(githubCLIHostsPath);
153
+ const configYAMLRaw = file.read(githubCLIHostsPath, verbose);
154
154
  const configYAML = yaml.parse(configYAMLRaw) as GitHubCLIHostsYAML;
155
155
 
156
156
  const githubCom = configYAML["github.com"];
@@ -159,7 +159,7 @@ function getGitHubUsername() {
159
159
  }
160
160
 
161
161
  const { user } = githubCom;
162
- if (user === "") {
162
+ if (user === undefined || user === "") {
163
163
  return undefined;
164
164
  }
165
165
 
@@ -27,7 +27,7 @@ export async function init(argv: Record<string, unknown>): Promise<void> {
27
27
  yes,
28
28
  );
29
29
  await checkIfProjectPathExists(projectPath, yes, verbose);
30
- const modsDirectory = await getModsDir(argv);
30
+ const modsDirectory = await getModsDir(argv, verbose);
31
31
  checkModSubdirectory(projectPath, modsDirectory);
32
32
  const projectName = path.basename(projectPath);
33
33
  await checkModTargetDirectory(modsDirectory, projectName, yes, verbose);
@@ -10,7 +10,7 @@ export function installVSCodeExtensions(
10
10
  VSCodeCommand: string,
11
11
  verbose: boolean,
12
12
  ): void {
13
- const extensions = getExtensionsFromJSON(projectPath);
13
+ const extensions = getExtensionsFromJSON(projectPath, verbose);
14
14
  for (const extensionName of extensions) {
15
15
  execShell(VSCodeCommand, ["--install-extension", extensionName], verbose);
16
16
  }
@@ -20,18 +20,18 @@ interface ExtensionsJSON {
20
20
  recommendations: string[];
21
21
  }
22
22
 
23
- function getExtensionsFromJSON(projectPath: string) {
23
+ function getExtensionsFromJSON(projectPath: string, verbose: boolean) {
24
24
  const extensionsJSONPath = path.join(
25
25
  projectPath,
26
26
  ".vscode",
27
27
  "extensions.json",
28
28
  );
29
29
 
30
- if (!file.exists(extensionsJSONPath)) {
30
+ if (!file.exists(extensionsJSONPath, verbose)) {
31
31
  return [];
32
32
  }
33
33
 
34
- const extensionsJSONRaw = file.read(extensionsJSONPath);
34
+ const extensionsJSONRaw = file.read(extensionsJSONPath, verbose);
35
35
 
36
36
  let extensionsJSON: ExtensionsJSON;
37
37
  try {
@@ -12,11 +12,11 @@ export function copyWatcherMod(config: Config, verbose: boolean): void {
12
12
  // Check to see if this mod was disabled
13
13
  const watcherModPath = path.join(config.modsDirectory, WATCHER_MOD_NAME);
14
14
  const disableItPath = path.join(watcherModPath, DISABLE_IT_FILE);
15
- const watcherModDisabled = file.exists(disableItPath);
15
+ const watcherModDisabled = file.exists(disableItPath, verbose);
16
16
 
17
17
  // Delete and re-copy the watcher mod every time IsaacScript starts
18
18
  // This ensures that it is always the latest version
19
- if (file.exists(watcherModPath)) {
19
+ if (file.exists(watcherModPath, verbose)) {
20
20
  file.deleteFileOrDirectory(watcherModPath, verbose);
21
21
  }
22
22
 
@@ -45,7 +45,7 @@ function disableIsaacScriptWatcherAutomaticRestart(
45
45
  verbose: boolean,
46
46
  ) {
47
47
  const mainLuaPath = path.join(watcherModPath, MAIN_LUA);
48
- const mainLua = file.read(mainLuaPath);
48
+ const mainLua = file.read(mainLuaPath, verbose);
49
49
 
50
50
  const modifiedMainLua = mainLua.replace(
51
51
  "local RESTART_GAME_ON_RECOMPILATION = true",
@@ -4,8 +4,8 @@ import { TSCONFIG_PATH } from "../../constants";
4
4
  import * as file from "../../file";
5
5
  import { error } from "../../utils";
6
6
 
7
- export function getTSConfigInclude(): string {
8
- const tsConfigRaw = file.read(TSCONFIG_PATH);
7
+ export function getTSConfigInclude(verbose: boolean): string {
8
+ const tsConfigRaw = file.read(TSCONFIG_PATH, verbose);
9
9
  let tsConfig: Record<string, string[]>;
10
10
  try {
11
11
  tsConfig = JSONC.parse(tsConfigRaw) as Record<string, string[]>;
@@ -47,11 +47,11 @@ function afterEachSync(params?: {
47
47
  }
48
48
 
49
49
  function onError(err: Error) {
50
- console.error("The directory syncer encountered an error:", err);
50
+ send(`The directory syncer encountered an error: ${err}`);
51
51
  }
52
52
 
53
53
  function send(msg: string) {
54
- if (typeof process.send === "function") {
54
+ if (process.send !== undefined) {
55
55
  process.send(msg);
56
56
  }
57
57
  }
@@ -29,7 +29,7 @@ export function monitor(argv: Record<string, unknown>, config: Config): void {
29
29
  }
30
30
 
31
31
  // Read the "tsconfig.json" file
32
- const tsConfigInclude = getTSConfigInclude();
32
+ const tsConfigInclude = getTSConfigInclude(verbose);
33
33
  const resolvedIncludePath = path.resolve(CWD, tsConfigInclude);
34
34
  const modTargetDirectoryName = getModTargetDirectoryName(config);
35
35
  const modTargetPath = path.join(config.modsDirectory, modTargetDirectoryName);
@@ -40,7 +40,7 @@ export function monitor(argv: Record<string, unknown>, config: Config): void {
40
40
 
41
41
  // Delete and re-copy the mod every time IsaacScript starts
42
42
  // This ensures that it is always the latest version
43
- if (file.exists(modTargetPath)) {
43
+ if (file.exists(modTargetPath, verbose)) {
44
44
  file.deleteFileOrDirectory(modTargetPath, true);
45
45
  }
46
46
 
@@ -1,24 +1,25 @@
1
- import chalk from "chalk";
2
1
  import * as JSONC from "jsonc-parser";
3
2
  import path from "path";
4
3
  import { PROJECT_NAME } from "../../../constants";
5
4
  import * as file from "../../../file";
6
- import { ensureAllCases, error } from "../../../utils";
5
+ import { ensureAllCases } from "../../../utils";
7
6
  import { SaveDatMessage, SaveDatMessageType } from "./types";
8
7
 
9
8
  const MAX_MESSAGES = 100;
9
+ const VERBOSE = false;
10
10
 
11
11
  let saveDatPath: string;
12
12
  let saveDatFileName: string;
13
13
 
14
- init();
14
+ init(VERBOSE);
15
15
 
16
- function init() {
16
+ function init(verbose: boolean) {
17
17
  const numArgs = 1;
18
18
  if (process.argv.length !== 2 + numArgs) {
19
- throw new Error(
20
- "The Save.dat writer process did not get the right amount of arguments.",
19
+ send(
20
+ "The save#.dat writer process did not get the right amount of arguments.",
21
21
  );
22
+ process.exit(1);
22
23
  }
23
24
 
24
25
  saveDatPath = process.argv[2];
@@ -26,8 +27,8 @@ function init() {
26
27
 
27
28
  // Check to see if the data directory exists
28
29
  const watcherModDataPath = path.dirname(saveDatPath);
29
- if (!file.exists(watcherModDataPath)) {
30
- file.makeDir(watcherModDataPath, false);
30
+ if (!file.exists(watcherModDataPath, verbose)) {
31
+ file.makeDir(watcherModDataPath, verbose);
31
32
  }
32
33
 
33
34
  // Listen for messages from the parent process
@@ -37,7 +38,7 @@ function init() {
37
38
  }
38
39
 
39
40
  function onMessage(type: SaveDatMessageType, data: string, numRetries = 0) {
40
- const saveDat = readSaveDatFromDisk();
41
+ const saveDat = readSaveDatFromDisk(VERBOSE);
41
42
  if (saveDat.length > MAX_MESSAGES) {
42
43
  // If IsaacScript is running and
43
44
  // 1) the game is not open
@@ -50,17 +51,18 @@ function onMessage(type: SaveDatMessageType, data: string, numRetries = 0) {
50
51
  return;
51
52
  }
52
53
  addMessageToSaveDat(type, saveDat, data); // Mutates saveDat
53
- writeSaveDatToDisk(type, data, saveDat, numRetries);
54
+ writeSaveDatToDisk(type, data, saveDat, numRetries, VERBOSE);
54
55
  }
55
56
 
56
- function readSaveDatFromDisk() {
57
+ function readSaveDatFromDisk(verbose: boolean) {
57
58
  let saveDat: SaveDatMessage[];
58
- if (file.exists(saveDatPath)) {
59
- const saveDatRaw = file.read(saveDatPath);
59
+ if (file.exists(saveDatPath, verbose)) {
60
+ const saveDatRaw = file.read(saveDatPath, verbose);
60
61
  try {
61
62
  saveDat = JSONC.parse(saveDatRaw) as SaveDatMessage[];
62
63
  } catch (err) {
63
- error(`Failed to parse "${chalk.green(saveDatPath)}":`, err);
64
+ send(`Failed to parse "${saveDatPath}": ${err}`);
65
+ process.exit(1);
64
66
  }
65
67
  } else {
66
68
  saveDat = [];
@@ -111,22 +113,22 @@ function writeSaveDatToDisk(
111
113
  type: SaveDatMessageType,
112
114
  data: string,
113
115
  saveDat: SaveDatMessage[],
114
- numRetries = 0,
116
+ numRetries: number,
117
+ verbose: boolean,
115
118
  ) {
116
119
  const saveDatRaw = JSON.stringify(saveDat, null, 2);
117
120
  try {
118
- file.writeTry(saveDatPath, saveDatRaw);
121
+ file.writeTry(saveDatPath, saveDatRaw, verbose);
119
122
  } catch (err) {
120
123
  if (numRetries > 4) {
121
- console.error(
124
+ send(
122
125
  `Failed to write to the ${saveDatFileName} for 5 times in a row. Maybe the file got locked somehow. ${PROJECT_NAME} will now exit.`,
123
126
  );
124
- console.error("The writing error is as follows:");
125
- console.error(err);
127
+ send(`The writing error is as follows: ${err}`);
126
128
  process.exit(1);
127
129
  }
128
130
 
129
- console.log(
131
+ send(
130
132
  `Writing to "${saveDatFileName}" failed. (The number of retries so far is ${numRetries}.) Trying again in 0.1 seconds...`,
131
133
  );
132
134
  setTimeout(() => {
@@ -134,3 +136,9 @@ function writeSaveDatToDisk(
134
136
  }, 100);
135
137
  }
136
138
  }
139
+
140
+ function send(msg: string) {
141
+ if (process.send !== undefined) {
142
+ process.send(msg);
143
+ }
144
+ }
@@ -9,7 +9,7 @@ let saveDatWriter: ChildProcess | null = null;
9
9
 
10
10
  export function spawnSaveDatWriter(config: Config): void {
11
11
  const processName = "saveDatWriter";
12
- const processDescription = "Save.dat writer";
12
+ const processDescription = "save#.dat writer";
13
13
  const processPath = path.join(__dirname, processName, processName);
14
14
  const modsDataPath = path.join(config.modsDirectory, "..", "data");
15
15
  const watcherModDataPath = path.join(modsDataPath, WATCHER_MOD_NAME);
@@ -9,12 +9,12 @@ export function touchWatcherSaveDatFiles(
9
9
  ): void {
10
10
  const modsDataPath = path.join(config.modsDirectory, "..", "data");
11
11
  const watcherModDataPath = path.join(modsDataPath, WATCHER_MOD_NAME);
12
- if (!file.exists(watcherModDataPath)) {
12
+ if (!file.exists(watcherModDataPath, verbose)) {
13
13
  file.makeDir(watcherModDataPath, verbose);
14
14
  }
15
15
  const saveDatFileName = `save${config.saveSlot}.dat`;
16
16
  const saveDatPath = path.join(watcherModDataPath, saveDatFileName);
17
- if (!file.exists(saveDatPath)) {
17
+ if (!file.exists(saveDatPath, verbose)) {
18
18
  file.touch(saveDatPath, verbose);
19
19
  }
20
20
  }