UNPKG

codess

Version:

vscode代码片段管理器,通过 本地包(本地某个文件夹) 或官网的 远程包(代码片段集合) 生成本地项目的 vscode 代码片段配置。

50 lines (49 loc) 2.32 kB
"use strict"; 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.init = init; const path_1 = __importDefault(require("path")); const config_1 = require("../config/config"); const inquirer_1 = __importDefault(require("inquirer")); const fs_1 = require("../utils/fs"); const saveSnippetsConfig_1 = require("../saveSnippetsConfig"); const packageJSON_1 = require("../config/packageJSON"); function init() { var _a; let p = Promise.resolve(); let configPath = path_1.default.join(process.cwd(), config_1.configName); if ((_a = (0, fs_1.statSync)(configPath)) === null || _a === void 0 ? void 0 : _a.isFile()) { p = inquirer_1.default .prompt({ type: 'confirm', name: 'confirm', message: `The configuration file already exists,Overlay or not: `, default: false, }) .then(({ confirm }) => confirm) .catch(() => false) .then((s) => { return s ? Promise.resolve() : Promise.reject(); }); } p.then(() => __awaiter(this, void 0, void 0, function* () { (0, config_1.setConfig)((0, config_1.getNullConfig)()); (0, saveSnippetsConfig_1.saveDefSnippets)(); console.log(`Try typing hhh ${packageJSON_1.packageJSON.name} or ${packageJSON_1.packageJSON.name .split('-') .map((_) => _[0]) .join('')},You can see the default code snippet prompts!`); })).catch(() => { }); }