diff --git a/README.md b/README.md index 351a110..8c49b6f 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" - } + }, + "pushAllOnConnection": false } ``` diff --git a/src/config.js b/src/config.js index e20a1a8..10feace 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" } + }, + pushAllOnConnection: { + doc: 'Push all files when initial connection is made.', + format: 'Boolean', + env: 'BB_CON_PUSH', + default: false } }); diff --git a/src/index.js b/src/index.js index 982a3e4..a014c85 100644 --- a/src/index.js +++ b/src/index.js @@ -23,8 +23,16 @@ export async function start() { signal.emit(EventType.MessageSend, requestDefinitionFile()); } - // Upload missing files to the game. - signal.emit(EventType.MessageSend, requestFilenames()); + if (config.get("pushAllOnConnection")) { + 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()); + } }) // Add a handler for changed files.