Skip to content

Commit

Permalink
fix: update path
Browse files Browse the repository at this point in the history
  • Loading branch information
gongmw committed Nov 25, 2020
1 parent 8c2d877 commit a641acc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bin/wept
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ const fs = require('fs');
const path = require('path');
const yargs = require('yargs');
const chalk = require('chalk');
const logs = require('../lib/logs');

const clearConsole = () => {
process.stdout.write(/^win/.test(process.platform) ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H');
}

const checkcompiledProject = (compiledPath) => {
const checkCompileProject = (compiledPath) => {
if (!compiledPath) throw new Error('小程序编译后项目路径不能为空');
if (!path.isAbsolute(compiledPath)) throw new Error('小程序编译后项目路径必须为绝对路径');
const parent = path.dirname(compiledPath);
Expand Down Expand Up @@ -42,7 +43,9 @@ const runWeb = async () => {
}

let compiledPath = path.resolve(cacheFolder, path.basename(appletSources));
checkAppletProject(compiledPath);
checkCompileProject(compiledPath);


};

const weptCli = async () => {
Expand All @@ -68,6 +71,6 @@ const weptCli = async () => {
};

weptCli().catch(err => {
console.log('%s %s %s', chalk.red(`[${(new Date()).toUTCString()}]`), chalk.red('[ERROR]'), chalk.red(err));
logs.error(err)
process.exit();
});
21 changes: 21 additions & 0 deletions lib/logs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';
const chalk = require('chalk');

module.exports = {
info: function (msg) {
console.log('%s %s %s', `[${(new Date()).toUTCString()}]`, '[INFO]', msg);
},
warn: function (msg) {
console.log('%s %s %s', chalk.yellow(`[${(new Date()).toUTCString()}]`), chalk.yellow('[WARN]'), chalk.yellow(msg));
},
success: function (msg) {
console.log('%s %s %s', chalk.green(`[${(new Date()).toUTCString()}]`), chalk.green('[SUCCESS]'), chalk.green(msg));
},
error: function (msg) {
if (msg instanceof Error) {
console.log('%s %s %s', chalk.red(`[${(new Date()).toUTCString()}]`), chalk.red('[ERROR]'), chalk.red(msg.stack));
} else {
console.log('%s %s %s', chalk.red(`[${(new Date()).toUTCString()}]`), chalk.red('[ERROR]'), chalk.red(msg));
}
}
};

0 comments on commit a641acc

Please sign in to comment.