Skip to content

Commit ffe389a

Browse files
committed
The index-hash tag strategy can be used for any file (via filePattern), so let's call it file-hash.
1 parent 0a1f446 commit ffe389a

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242
willDeploy: function(context) {
4343
var deployment = context.deployment;
4444
var ui = deployment.ui;
45-
var config = deployment.config[this.name] || {};
45+
var config = deployment.config[this.name] = deployment.config[this.name] || {};
4646

4747
return validateConfig(ui, config)
4848
.then(function() {

lib/tags/index-hash.js renamed to lib/tags/file-hash.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var fs = require('fs');
33
var path = require('path');
44
var minimatch = require('minimatch');
55
var Fingerprint = require('broccoli-asset-rev/lib/fingerprint');
6+
var Promise = require('ember-cli/lib/ext/promise');
67

78
var denodeify = require('rsvp').denodeify;
89
var readFile = denodeify(fs.readFile);
@@ -22,7 +23,7 @@ module.exports = CoreObject.extend({
2223
var filePaths = distFiles.filter(minimatch.filter(filePattern, { matchBase: true }));
2324

2425
if (!filePaths.length) {
25-
return Promise.reject('`' + filePattern + '` does not exist in distDir');
26+
return Promise.reject('`' + filePattern + '` does not exist in distDir `' + distDir + '`');
2627
}
2728

2829
var filePath = path.join(distDir, filePaths[0]);

lib/tags/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
"index-hash": require('./index-hash')
2+
"file-hash": require('./file-hash')
33
};

lib/utilities/validate-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = function(ui, config) {
99
ui.writeLine(blue('- validating config'));
1010

1111
var defaultConfig = {
12-
type: 'index-hash',
12+
type: 'file-hash',
1313
filePattern: 'index.html'
1414
};
1515

tests/unit/index-nodetest.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('the index', function() {
3939
},
4040
config: {
4141
tag: {
42-
type: 'index-hash',
42+
type: 'file-hash',
4343
filePattern: 'eeee'
4444
}
4545
}
@@ -57,7 +57,7 @@ describe('the index', function() {
5757
});
5858

5959
var context = {
60-
distDir: process.cwd() + '/tests/fixtures',
60+
distDir: 'tests/fixtures',
6161
distFiles: ['index.html'],
6262
deployment: {
6363
ui: {
@@ -66,7 +66,7 @@ describe('the index', function() {
6666
},
6767
config: {
6868
tag: {
69-
type: 'index-hash',
69+
type: 'file-hash',
7070
filePattern: 'index.html'
7171
},
7272
}

tests/unit/lib/tags/index-hash-nodetest.js renamed to tests/unit/lib/tags/file-hash-nodetest.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
var assert = require('ember-cli/tests/helpers/assert');
44

5-
describe('the index-hash tag', function() {
5+
describe('the file-hash tag', function() {
66
var Tag;
77

88
before(function() {
9-
Tag = require('../../../../lib/tags/index-hash');
9+
Tag = require('../../../../lib/tags/file-hash');
1010
});
1111

1212
describe('#generate', function() {
1313
it ('generates a hash of the supplied index file', function() {
1414
var subject = new Tag({
1515
context: {
16-
distDir: process.cwd() + '/tests/fixtures',
16+
distDir: 'tests/fixtures',
1717
distFiles: ['index.html'],
1818
},
1919
config: {
@@ -30,7 +30,7 @@ describe('the index-hash tag', function() {
3030
it('rejects when the filePattern doesn\'t exist in distFiles', function() {
3131
var subject = new Tag({
3232
context: {
33-
distDir: process.cwd() + '/tests/fixtures',
33+
distDir: 'tests/fixtures',
3434
distFiles: ['index.html']
3535
},
3636
config: {
@@ -40,14 +40,14 @@ describe('the index-hash tag', function() {
4040

4141
return assert.isRejected(subject.generate())
4242
.then(function(error) {
43-
assert.equal(error, '`some-file-that-does-not-exist` does not exist in distDir');
43+
assert.equal(error, '`some-file-that-does-not-exist` does not exist in distDir `tests/fixtures`');
4444
});
4545
});
4646

4747
it('rejects when the file doesn\'t exist', function() {
4848
var subject = new Tag({
4949
context: {
50-
distDir: process.cwd() + '/tests/fixtures',
50+
distDir: 'tests/fixtures',
5151
distFiles: ['index.xxx']
5252
},
5353
config: {

0 commit comments

Comments
 (0)