UNPKG

svelte-draft

Version:
31 lines (30 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = require("path"); const fs_extra_1 = require("fs-extra"); const child_process_1 = require("child_process"); function generateType(include, outDir) { const workingDirectory = process.cwd(); const typeConfigPath = path_1.resolve(__dirname, "temp.typeconfig.json"); fs_extra_1.outputJSONSync(typeConfigPath, { compilerOptions: { target: "es6", module: "commonjs", moduleResolution: "node", jsx: "preserve", declaration: true, outDir: path_1.resolve(workingDirectory, outDir), emitDeclarationOnly: true, esModuleInterop: true, }, include: include.map(each => path_1.resolve(workingDirectory, each)), }); child_process_1.exec(`npx tsc --project ${typeConfigPath}`, error => { // TODO: fix error report: [svelte] Cannot find module 'magic-string' // if (error) { // console.log(error); // } fs_extra_1.removeSync(typeConfigPath); }); } exports.generateType = generateType;