Skip to content

Commit

Permalink
fix: #379 (#455)
Browse files Browse the repository at this point in the history
Co-authored-by: Harry Chen <[email protected]>
(cherry picked from commit 1e7eb84)
  • Loading branch information
SuperHuangXu authored and czy88840616 committed Apr 10, 2020
1 parent d4f48c7 commit 5d5b5be
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions packages/midway-bin/lib/cmd/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

const Command = require('egg-bin').Command;
const rimraf = require('mz-modules/rimraf');
const cp = require('child_process');
const path = require('path');
const fs = require('fs');
const fseExtra = require('fs-extra');

class CleanCommand extends Command {
constructor(rawArgv) {
Expand All @@ -27,17 +27,18 @@ class CleanCommand extends Command {

async cleanDir(cwd) {
await new Promise((resolve, reject) => {
cp.exec('find . -type d -name \'logs\' -or -name \'run\' -or -name \'.nodejs-cache\' | xargs rm -rf', {
cwd,
}, error => {
if (error) {
console.error(`[midway-bin] exec error: ${error}`);
reject(error);
return;
}
const rmDirName = [ 'logs', 'run', '.nodejs-cache' ];
try {
rmDirName.forEach(name => {
fseExtra.removeSync(path.join(cwd, name));
});
console.log('[midway-bin] clean midway temporary files complete!');
resolve();
});
} catch (error) {
console.error(`[midway-bin] exec error: ${error}`);
reject(error);
return;
}
});

const pkg = require(path.join(cwd, 'package.json'));
Expand Down

0 comments on commit 5d5b5be

Please sign in to comment.