From f3ef45c197fd1efeb51444294be78dd18cbc0f1f Mon Sep 17 00:00:00 2001 From: hotoo Date: Tue, 7 Oct 2014 08:35:00 +0800 Subject: [PATCH] Refact source argument. --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6044e6d..924aecc 100644 --- a/index.js +++ b/index.js @@ -12,12 +12,12 @@ var DEFAULT_PORT = 8000; var DEFAULT_ENCODE = "utf-8"; function build(cwd, options){ - var fileName = options.args.join(""); + var fileName = options.args[0] || ""; var encode = options.encode || DEFAULT_ENCODE; var template_dir = path.join(__dirname, "template"); var dist_dir = options.dist || path.join(cwd, DEFAULT_DIST); - if (!fs.existsSync(fileName)) { + if (!fileName || !fs.existsSync(fileName)) { console.error("Not Found:", fileName); return; } @@ -39,9 +39,9 @@ function server(cwd, options){ var port = options.port || DEFAULT_PORT; var encode = options.encode || DEFAULT_ENCODE; var watch = options.watch || false; - var fileName = options.args.join(""); + var fileName = options.args[0] || ""; - if (!fs.existsSync(fileName)) { + if (!fileName || !fs.existsSync(fileName)) { console.error("Not Found:", fileName); return; }