From 0a730a5e2f8e9312d7883d37c5ac3e3451e7d781 Mon Sep 17 00:00:00 2001 From: ZhaZhengRefn <512557403@qq.com> Date: Fri, 16 Feb 2018 17:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsync=E5=91=BD=E5=90=8DBug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/pharah | 2 +- commands/sync.js | 8 +++++--- package.json | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/pharah b/bin/pharah index 89be2d0..5cc4fd2 100644 --- a/bin/pharah +++ b/bin/pharah @@ -3,7 +3,7 @@ const program = require('commander') const path = require('path') -const req = command => path.resolve('./commands/', command) +const req = command => path.resolve(__dirname, '../commands/', command) program .version(require('../package.json').version, '-v, --version') diff --git a/commands/sync.js b/commands/sync.js index a8cc630..b7790b2 100644 --- a/commands/sync.js +++ b/commands/sync.js @@ -34,9 +34,8 @@ module.exports = inquirer.prompt([ } ]) .then(({ url, mode }) => { - download(url, path.resolve(__dirname, '../'), { encoding: 'utf8' }) + download(url, { encoding: 'utf8' }) .then(data => { - try { data = JSON.parse(data) } catch (error) { @@ -46,8 +45,11 @@ module.exports = inquirer.prompt([ if(mode === 'merge'){ templateList = Object.assign(templateList, data) } else if(mode === 'replace'){ - templateList = data + templateList = Object.assign({}, data) } writeTemplateList(templateList, path.resolve(__dirname, '../template.json')) }) + .catch(e => { + console.log(e) + }) }) \ No newline at end of file diff --git a/package.json b/package.json index 1f45f9d..db6bd01 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "pharah-cli", - "version": "1.0.4", + "version": "1.0.7", "description": "A cli that aims to managing template code.", "main": "index.js", "bin": { - "pharah": "./bin/pharah" + "pharah": "bin/pharah" }, "scripts": {}, "repository": {