Skip to content

Commit

Permalink
fix: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Nov 20, 2019
1 parent 99368c3 commit 77177fb
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions packages/midway-bin/lib/cmd/build.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -100,19 +100,19 @@ 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);
// 目录,或者不含通配符的普通文件
this.copyFile(srcDir, targetDir, cwd);
} 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(
Expand Down

0 comments on commit 77177fb

Please sign in to comment.