Skip to content

Commit c0b7cf1

Browse files
author
Amiel Martin
committed
Fix case distDir is an absolute path
Before, if `distDir` was an absolute path, `absoluteInputPath` would end up having rootPath doubled. This uses `path.resolve` instead of `path.join` to resolve that issue.
1 parent c4d949b commit c0b7cf1

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-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: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
/* globals require, describe, before, beforeEach, it, process */
4+
35
var fs = require('fs');
46
var path = require('path');
57
var assert = require('ember-cli/tests/helpers/assert');
@@ -8,9 +10,11 @@ describe('the deploy plugin object', function() {
810
var fakeRoot;
911
var plugin;
1012
var promise;
13+
var distDir;
1114

1215
before(function() {
13-
fakeRoot = process.cwd() + '/tests/fixtures';
16+
fakeRoot = process.cwd() + '/tests/fixtures';
17+
distDir = 'dist';
1418
});
1519

1620
beforeEach(function() {
@@ -33,7 +37,7 @@ describe('the deploy plugin object', function() {
3337
fileInputPattern: 'index.html',
3438
fileOutputPattern: 'index.json',
3539
distDir: function(context) {
36-
return 'dist';
40+
return distDir;
3741
},
3842
projectRoot: function(context) {
3943
return fakeRoot;
@@ -80,5 +84,22 @@ describe('the deploy plugin object', function() {
8084
assert.deepEqual(result.distFiles, ['index.json']);
8185
});
8286
});
87+
88+
describe('when the distDir is an absolute path', function() {
89+
before(function() {
90+
distDir = fakeRoot + '/dist';
91+
});
92+
93+
it('still works', function() {
94+
return assert.isFulfilled(promise)
95+
.then(function() {
96+
var json = require(fakeRoot + '/dist/index.json');
97+
98+
assert.equal(Object.keys(json).length, 4);
99+
});
100+
});
101+
102+
103+
});
83104
});
84105
});

0 commit comments

Comments
 (0)