UNPKG

@titan-suite/cli

Version:

The complete smart contract development tool

53 lines (52 loc) 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const command_1 = require("@oclif/command"); const chalk_1 = require("chalk"); const fs = require("fs"); const inquirer_1 = require("inquirer"); const index_1 = require("../utils/index"); class Init extends command_1.Command { run() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { args } = this.parse(Init); if (args.newFolder) { yield index_1.downloadPack('default', `${args.newFolder}`); } else { fs.readdir(process.cwd(), (err, files) => tslib_1.__awaiter(this, void 0, void 0, function* () { if (err) throw err; if (files.length) { this.log(chalk_1.default ` {yellow.bold WARNING} {yellow Some existing files may be overwritten.} `); const answer = yield inquirer_1.prompt([ { type: 'list', name: 'overwrite', message: 'Do you want to continue?', choices: ['Yes', 'No'] } ]); answer.overwrite === 'Yes' ? index_1.downloadPack('default') : this.log('aborting...'); } else { yield index_1.downloadPack('default'); } })); } }); } } Init.description = 'Create a new Titan environment'; Init.examples = [ '$ titan init', '$ titan init <name>', ]; Init.flags = { help: command_1.flags.help({ char: 'h' }), }; Init.args = [{ name: 'newFolder' }]; exports.default = Init;