Skip to content

Commit

Permalink
feat: add new doc command
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Feb 12, 2019
1 parent 16fdbad commit 972db71
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/midway-bin/bin/midway-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

'use strict';

const Command = require('../');
const Command = require('../').MidwayBin;
new Command().start();
3 changes: 2 additions & 1 deletion packages/midway-bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MidwayBin extends Command {
}
}

module.exports = exports = MidwayBin;
exports.MidwayBin = MidwayBin;
exports.AutodCommand = require('./lib/cmd/autod');
exports.BuildCommand = require('./lib/cmd/build');
exports.CovCommand = require('./lib/cmd/cov');
Expand All @@ -21,3 +21,4 @@ exports.TestCommand = require('./lib/cmd/test');
exports.DebugCommand = require('./lib/cmd/debug');
exports.PkgfilesCommand = require('./lib/cmd/pkgfiles');
exports.CleanCommand = require('./lib/cmd/clean');
exports.DocCommand = require('./lib/cmd/doc');
28 changes: 28 additions & 0 deletions packages/midway-bin/lib/cmd/doc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

const Command = require('egg-bin').Command;
const cp = require('child_process');
const path = require('path');
const fs = require('fs');

class DocCommand extends Command {
constructor(rawArgv) {
super(rawArgv);
this.usage = 'Usage: midway-bin doc';
}

get description() {
return 'generate typescript document';
}

* run(context) {
const { cwd } = context;
if (!fs.existsSync(path.join(cwd, 'package.json'))) {
console.log(`[midway-bin] package.json not found in ${cwd}\n`);
return;
}
yield this.cleanDir(cwd);
}
}

module.exports = DocCommand;

0 comments on commit 972db71

Please sign in to comment.