Skip to content

Commit b775303

Browse files
committed
Merge pull request #16 from amiel/fix-absolute-dist-dir
Fix case distDir is an absolute path
2 parents 54d8259 + 4596dd9 commit b775303

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ module.exports = {
5656
var fileOutputPattern = this.readConfig('fileOutputPattern');
5757
var inputPath = path.join(distDir, fileInputPattern);
5858
var outputPath = path.join(distDir, fileOutputPattern);
59-
var absoluteInputPath = path.join(root, inputPath);
60-
var absoluteOutputPath = path.join(root, outputPath);
59+
var absoluteInputPath = path.resolve(root, inputPath);
60+
var absoluteOutputPath = path.resolve(root, outputPath);
6161

6262
this.log('generating `' + outputPath + '` from `' + inputPath + '`', { verbose: true });
6363

tests/unit/index-nodetest.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ describe('the deploy plugin object', function() {
88
var fakeRoot;
99
var plugin;
1010
var promise;
11+
var distDir;
1112

1213
before(function() {
13-
fakeRoot = process.cwd() + '/tests/fixtures';
14+
fakeRoot = process.cwd() + '/tests/fixtures';
15+
distDir = 'dist';
1416
});
1517

1618
beforeEach(function() {
@@ -33,7 +35,7 @@ describe('the deploy plugin object', function() {
3335
fileInputPattern: 'index.html',
3436
fileOutputPattern: 'index.json',
3537
distDir: function(context) {
36-
return 'dist';
38+
return distDir;
3739
},
3840
projectRoot: function(context) {
3941
return fakeRoot;
@@ -80,5 +82,20 @@ describe('the deploy plugin object', function() {
8082
assert.deepEqual(result.distFiles, ['index.json']);
8183
});
8284
});
85+
86+
describe('when the distDir is an absolute path', function() {
87+
before(function() {
88+
distDir = fakeRoot + '/dist';
89+
});
90+
91+
it('still works', function() {
92+
return assert.isFulfilled(promise)
93+
.then(function() {
94+
var json = require(fakeRoot + '/dist/index.json');
95+
96+
assert.equal(Object.keys(json).length, 4);
97+
});
98+
});
99+
});
83100
});
84101
});

0 commit comments

Comments
 (0)