From 64761fa9d78b5a651d87653854572cfbd6c1b5b4 Mon Sep 17 00:00:00 2001 From: RyanHx Date: Sun, 28 Aug 2022 15:12:17 +0100 Subject: [PATCH 1/5] Add pushOnCon option --- src/config.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/config.js b/src/config.js index e20a1a8..e24b4ef 100644 --- a/src/config.js +++ b/src/config.js @@ -52,6 +52,12 @@ export let config = convict({ env: 'BB_LOCATION_DEF', default: "./NetScriptDefinitions.d.ts" } + }, + pushOnCon: { + doc: 'Push all files when initial connection is made.', + format: 'Boolean', + env: 'BB_CON_PUSH', + default: false } }); From 53a872a11b5f204cdf3899120c1bf4a9a03a0ad7 Mon Sep 17 00:00:00 2001 From: RyanHx Date: Sun, 28 Aug 2022 15:12:36 +0100 Subject: [PATCH 2/5] Emit MessageSend for every file --- src/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/index.js b/src/index.js index 982a3e4..8d317a7 100644 --- a/src/index.js +++ b/src/index.js @@ -25,6 +25,14 @@ export async function start() { // Upload missing files to the game. signal.emit(EventType.MessageSend, requestFilenames()); + + if (config.get("pushOnCon")) { + const extensions = config.get("allowedFiletypes"); + for (const path of watch.paths.keys()) { + if (extensions.some(extension => path.endsWith(extension))) + signal.emit(EventType.MessageSend, fileChangeEventToMsg({ path: path })) + } + } }) // Add a handler for changed files. From fdebd610b13042108bee4d73e25a50c10837a28d Mon Sep 17 00:00:00 2001 From: RyanHx Date: Sun, 28 Aug 2022 15:16:00 +0100 Subject: [PATCH 3/5] Update example --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 351a110..a561099 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Here's an example of it's contents: "definitionFile": { "update": false, "location": "NetScriptDefinitions.d.ts" - } + }, + "pushOnCon": false } ``` From e37990afab3dba658c3d217656b379b4564fe5b6 Mon Sep 17 00:00:00 2001 From: RyanHx Date: Sun, 28 Aug 2022 15:54:42 +0100 Subject: [PATCH 4/5] No need for extra event if push all --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 8d317a7..19a2721 100644 --- a/src/index.js +++ b/src/index.js @@ -23,15 +23,15 @@ export async function start() { signal.emit(EventType.MessageSend, requestDefinitionFile()); } - // Upload missing files to the game. - signal.emit(EventType.MessageSend, requestFilenames()); - if (config.get("pushOnCon")) { const extensions = config.get("allowedFiletypes"); for (const path of watch.paths.keys()) { if (extensions.some(extension => path.endsWith(extension))) signal.emit(EventType.MessageSend, fileChangeEventToMsg({ path: path })) } + } else { + // Upload missing files to the game. + signal.emit(EventType.MessageSend, requestFilenames()); } }) From e05a445544456a99b71c722c7a960f304028dc00 Mon Sep 17 00:00:00 2001 From: RyanHx Date: Sun, 28 Aug 2022 15:55:57 +0100 Subject: [PATCH 5/5] Descriptive config name --- README.md | 2 +- src/config.js | 2 +- src/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a561099..8c49b6f 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,6 @@ Here's an example of it's contents: "update": false, "location": "NetScriptDefinitions.d.ts" }, - "pushOnCon": false + "pushAllOnConnection": false } ``` diff --git a/src/config.js b/src/config.js index e24b4ef..10feace 100644 --- a/src/config.js +++ b/src/config.js @@ -53,7 +53,7 @@ export let config = convict({ default: "./NetScriptDefinitions.d.ts" } }, - pushOnCon: { + pushAllOnConnection: { doc: 'Push all files when initial connection is made.', format: 'Boolean', env: 'BB_CON_PUSH', diff --git a/src/index.js b/src/index.js index 19a2721..a014c85 100644 --- a/src/index.js +++ b/src/index.js @@ -23,7 +23,7 @@ export async function start() { signal.emit(EventType.MessageSend, requestDefinitionFile()); } - if (config.get("pushOnCon")) { + if (config.get("pushAllOnConnection")) { const extensions = config.get("allowedFiletypes"); for (const path of watch.paths.keys()) { if (extensions.some(extension => path.endsWith(extension)))