diff --git a/.steamer/task/git-commit.js b/.steamer/task/git-commit.js old mode 100755 new mode 100644 diff --git a/.steamer/task/git-pull.js b/.steamer/task/git-pull.js old mode 100755 new mode 100644 diff --git a/.steamer/task/git-push.js b/.steamer/task/git-push.js old mode 100755 new mode 100644 diff --git a/index.js b/index.js index 962b254..d3e69f8 100755 --- a/index.js +++ b/index.js @@ -80,7 +80,7 @@ class TaskPlugin extends SteamerPlugin { let pkgJson = {}; if (this.fs.existsSync(pkgJsonPath)) { - pkgJson = require(path.join(taskPath, 'package.json')); + pkgJson = require(pkgJsonPath); } let dependencies = pkgJson.dependencies || {}; diff --git a/test/test.js b/test/test.js index 9bf6073..b6ad82e 100755 --- a/test/test.js +++ b/test/test.js @@ -39,11 +39,13 @@ describe('add', function() { let existCount = 0; let existsSyncStub = sinon.stub(task.fs, 'existsSync').callsFake((taskPath) => { - // console.log(taskPath, taskPath.includes('steamer-plugin-task.js')); if (!existCount && taskPath.includes('node_modules/steamer-task-alloyteam')) { existCount++; return false; } + if (taskPath.includes('package.json')) { + return false; + } return true; }); let spawnSyncStub = sinon.stub(task.spawn, 'sync').callsFake((npm, cmds, options) => { @@ -64,6 +66,9 @@ describe('add', function() { } copyCount++; }); + let readdirSyncStub = sinon.stub(task.fs, 'readdirSync').callsFake((dirPath) => { + return ['steamer-plugin-jb.js', 'steamer-plugin-task.js', 'task']; + }); let infoStub = sinon.stub(task, 'info'); let successStub = sinon.stub(task, 'success'); @@ -81,6 +86,7 @@ describe('add', function() { coppySyncStub.restore(); infoStub.restore(); successStub.restore(); + readdirSyncStub.restore(); }); });