mirror of
https://github.com/araxiaonline/wow-eluna-ts-module.git
synced 2026-06-13 02:42:22 -04:00
Added ETS snippets command to install built snippets to local vscode directory
This commit is contained in:
33
.bin/ets.js
33
.bin/ets.js
@@ -54,6 +54,14 @@ program
|
||||
deploy(env);
|
||||
});
|
||||
|
||||
program
|
||||
.command("snippets")
|
||||
.requiredOption("-t, --type <type>", "There are two sets of snippets, eluna: server side events and wowapi: used for building UIs for AIO/Addons", 'eluna')
|
||||
.description("This installs snippets that enable shortcuts to generating code in vscode. The snippets are copied to the current vscode project directory prefixed by type")
|
||||
.action(async ({type}) => {
|
||||
installSnippets(type);
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
/**
|
||||
@@ -348,6 +356,31 @@ function buildModules(luaDir, moduleDir, watch, liveReload) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This will install snippets into the current project
|
||||
* @param {string} type - eluna | wowapi
|
||||
*/
|
||||
async function installSnippets(type) {
|
||||
if(type !== 'eluna' && type !== 'wowapi') {
|
||||
log.error("Invalid snippet type. Must be eluna or wowapi");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if(type === 'wowapi') {
|
||||
log.error("wowapi snippets not yet implemented, in development add a comment to existing feature request to raise priority.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const snippetsFile = path.resolve(__dirname, `../dist/.vscode/${type}.code-snippets`);
|
||||
const vscodeDir = path.resolve(process.cwd(), '.vscode');
|
||||
|
||||
if(!fs.existsSync(vscodeDir)) {
|
||||
fs.mkdirSync(vscodeDir);
|
||||
}
|
||||
|
||||
fs.copyFileSync(snippetsFile, path.resolve(vscodeDir, `${type}.code-snippets`));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Environment Variable if found or return false.
|
||||
* @param {string} name
|
||||
|
||||
Reference in New Issue
Block a user