Merge pull request #2 from RyanHx/push-on-conn

Push all files on connection
This commit is contained in:
Alt 2022-08-28 17:09:31 +02:00 committed by GitHub
commit 5520fa3430
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View file

@ -34,6 +34,7 @@ Here's an example of it's contents:
"definitionFile": {
"update": false,
"location": "NetScriptDefinitions.d.ts"
}
},
"pushAllOnConnection": false
}
```

View file

@ -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
}
});

View file

@ -23,8 +23,16 @@ export async function start() {
signal.emit(EventType.MessageSend, requestDefinitionFile());
}
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.