tools/ts/tools.install.ts

39 lines
1.3 KiB
TypeScript
Raw Normal View History

2018-06-07 20:41:25 +00:00
import plugins = require('./tools.plugins');
import paths = require('./tools.paths');
2019-06-17 08:26:26 +00:00
import { logger } from './tools.logging';
2018-06-07 20:41:25 +00:00
const installExec = async (packageNames: string[]) => {
2019-06-17 08:26:26 +00:00
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
2018-06-07 20:41:25 +00:00
let installString = '';
2019-06-17 08:26:26 +00:00
for (const packageName of packageNames) {
logger.log('info', `Found ${packageName}!`);
2018-06-07 20:41:25 +00:00
installString = installString + `${packageName} `;
}
2019-06-17 08:26:26 +00:00
// lets remove old packages
const uninstallCommand = `npm uninstall -g ${installString}`;
const installCommand = `npm install -g ${installString}`;
logger.log('info', `uninstalling old packages with "${uninstallCommand}"`);
await smartshellInstance.exec(uninstallCommand);
logger.log('info', `installing tools with ${installCommand}`);
await smartshellInstance.exec(installCommand);
logger.log('ok', `installed tools successfully!`);
2018-06-07 20:41:25 +00:00
};
2019-06-17 08:26:26 +00:00
const packageLibrary = plugins.smartfile.fs.toObjectSync(
2018-06-07 20:41:25 +00:00
plugins.path.join(paths.packageBase, 'package_library.json')
);
2019-06-17 08:26:26 +00:00
export const install = async (packageSetArg: string) => {
2018-06-07 20:41:25 +00:00
switch (packageSetArg) {
case 'default':
await installExec(packageLibrary.default);
break;
default:
2019-06-17 08:26:26 +00:00
logger.log('warn', 'no set has been specified');
2018-06-07 20:41:25 +00:00
break;
}
};