From 77177fbec25064f881dc10f72a46dd14195de057 Mon Sep 17 00:00:00 2001 From: Harry Chen Date: Wed, 20 Nov 2019 11:46:46 +0800 Subject: [PATCH] fix: fix lint --- packages/midway-bin/lib/cmd/build.js | 62 ++++++++++++++-------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/packages/midway-bin/lib/cmd/build.js b/packages/midway-bin/lib/cmd/build.js index 5dbcd6f33585..5e2509e7197d 100644 --- a/packages/midway-bin/lib/cmd/build.js +++ b/packages/midway-bin/lib/cmd/build.js @@ -1,45 +1,45 @@ -"use strict"; +'use strict'; -const Command = require("egg-bin").Command; -const path = require("path"); -const fs = require("fs"); -const rimraf = require("mz-modules/rimraf"); -const fse = require("fs-extra"); -const globby = require("globby"); +const Command = require('egg-bin').Command; +const path = require('path'); +const fs = require('fs'); +const rimraf = require('mz-modules/rimraf'); +const fse = require('fs-extra'); +const globby = require('globby'); class BuildCommand extends Command { constructor(rawArgv) { super(rawArgv); - this.usage = "Usage: midway-bin build [options]"; + this.usage = 'Usage: midway-bin build [options]'; this.options = { clean: { - description: "clean build target dir", - type: "boolean", - alias: "c" + description: 'clean build target dir', + type: 'boolean', + alias: 'c', }, project: { - description: "project file location", - type: "string", - alias: "p", - default: "tsconfig.json" + description: 'project file location', + type: 'string', + alias: 'p', + default: 'tsconfig.json', }, srcDir: { - description: "source code path", - type: "string", - default: "src" - } + description: 'source code path', + type: 'string', + default: 'src', + }, }; } get description() { - return "build application automatically"; + return 'build application automatically'; } - *run(context) { + * run(context) { const { cwd, argv } = context; - const tscCli = require.resolve("typescript/bin/tsc"); + const tscCli = require.resolve('typescript/bin/tsc'); if (!fs.existsSync(path.join(cwd, argv.project))) { console.log(`[midway-bin] tsconfig.json not found in ${cwd}\n`); return; @@ -54,13 +54,13 @@ class BuildCommand extends Command { const args = []; if (argv.project) { - args.push("-p"); + args.push('-p'); args.push(argv.project); } yield this.helper.forkNode(tscCli, args, { cwd }); } - *cleanDir(cwd, projectFile) { + * cleanDir(cwd, projectFile) { const tsConfig = require(path.join(cwd, projectFile)); // if projectFile extended and without outDir, @@ -83,7 +83,7 @@ class BuildCommand extends Command { } } - *copyFiles(cwd, projectFile, argv) { + * copyFiles(cwd, projectFile, argv) { const tsConfig = require(path.join(cwd, projectFile)); // if projectFile extended and without outDir, @@ -100,11 +100,11 @@ class BuildCommand extends Command { if (tsConfig && tsConfig.compilerOptions) { const outDir = tsConfig.compilerOptions.outDir; - if (outDir && fs.existsSync(path.join(cwd, "package.json"))) { - const pkg = require(path.join(cwd, "package.json")); - if (pkg["midway-bin-build"] && pkg["midway-bin-build"].include) { - for (const file of pkg["midway-bin-build"].include) { - if (typeof file === "string" && !/\*/.test(file)) { + if (outDir && fs.existsSync(path.join(cwd, 'package.json'))) { + const pkg = require(path.join(cwd, 'package.json')); + if (pkg['midway-bin-build'] && pkg['midway-bin-build'].include) { + for (const file of pkg['midway-bin-build'].include) { + if (typeof file === 'string' && !/\*/.test(file)) { const srcDir = path.join(argv.srcDir, file); const targetDir = path.join(outDir, file); // 目录,或者不含通配符的普通文件 @@ -112,7 +112,7 @@ class BuildCommand extends Command { } else { // 通配符的情况 const paths = yield globby([].concat(file), { - cwd: path.join(cwd, argv.srcDir) + cwd: path.join(cwd, argv.srcDir), }); for (const p of paths) { this.copyFile(