sharechat-setup
Version:
A generic cli to setup mundane node tasks
37 lines • 1.93 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import cp from 'child_process';
import { InstallationDependenciesMap, PackageManager, } from './helpers/getUserPackageManager';
import prompt from 'prompt';
import chalk from 'chalk';
const init = () => __awaiter(void 0, void 0, void 0, function* () {
prompt.start();
prompt.get([
{
name: 'packageManager',
description: `Whats your choice of package manager? should be one of ${Object.values(PackageManager)}`,
enum: Object.values(PackageManager),
required: false,
default: 'npm',
},
], (err, result) => __awaiter(void 0, void 0, void 0, function* () {
const packageManager = result.packageManager;
yield cp.execSync(InstallationDependenciesMap[packageManager]('husky'));
yield cp.execSync('npx husky install');
yield cp.execSync(`npm pkg set scripts.prepare="husky install"`);
yield cp.execSync(`npx husky add .husky/pre-commit "npm test"`);
console.log('====================================');
console.log(chalk.bgMagenta.magenta('Successfully installed husky'));
console.log('====================================');
}));
});
init();
//# sourceMappingURL=index.js.map