Skip to content

Commit 345c376

Browse files
committed
Updated readme, version, adding note about fingerprint name format
1 parent ef931f1 commit 345c376

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ ASSET_FINGERPRINT = '0556f9ab7cbd607d10ed'
126126
CUSTOM_ASSET_FINGERPRINT = '921dcffe35e5f2740ef5'
127127
```
128128

129+
The format for the fingerprint name must uppercase separating words with underscore i.e. "CUSTOM_ASSET_FINGERPRINT". The name also needs to end with "_FINGERPRINT".
130+
129131

130132
### Credit
131133
Concept adapted from @samullen - http://samuelmullen.com/articles/replacing-the-rails-asset-pipeline-with-webpack-and-yarn/

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function AssetFingerprint(initializerDirectory, needsFingerprint = true, fingerp
2424

2525
function _validateFingerprintName(fingerprintName) {
2626
if(!/^([A-Z]|_)*_FINGERPRINT$/.test(fingerprintName)) {
27-
throw new Error('Please supply a fingerprint name that is all caps separating words by underscores (i.e. CUSTOM_ASSET_FINGERPRINT).');
27+
throw new Error('Please supply a fingerprint name that is all caps separating words by underscores ending with "_FINGERPRINT" (i.e. CUSTOM_ASSET_FINGERPRINT).');
2828
}
2929
}
3030

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "asset-fingerprint-webpack-rails",
3-
"version": "1.1.1",
3+
"version": "1.2.1",
44
"description": "A webpack plugin to fingerprint your JS for consumption by Rails",
55
"main": "index.js",
66
"scripts": {

spec/indexSpec.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,16 @@ describe("AssetFingerprint", function() {
6767
fingerprint = new AssetFingerprint(dir, true, "TEST_FINGERPRINT");
6868
expect(fingerprint.fingerprintName).toEqual("TEST_FINGERPRINT");
6969
});
70+
71+
it("should not validate when file does not exist.", function () {
72+
var dir = 'config/initializers';
73+
fingerprint = new AssetFingerprint(dir, true, "TEST_FINGERPRINT");
74+
expect(fingerprint.fingerprintName).toEqual("TEST_FINGERPRINT");
75+
});
7076
});
7177

7278
describe("fingerprint name", function() {
79+
const formatErrorMessage = 'Please supply a fingerprint name that is all caps separating words by underscores ending with "_FINGERPRINT" (i.e. CUSTOM_ASSET_FINGERPRINT).';
7380
beforeEach(function() {
7481
spyOn(fs, "existsSync").and.returnValue(true);
7582
spyOn(fs, "readFileSync").and.returnValue("TEST_FINGERPRINT");
@@ -84,13 +91,13 @@ describe("AssetFingerprint", function() {
8491
it("should validate the file name characters.", function() {
8592
var dir = 'config/initializers';
8693
fingerprint = function() { new AssetFingerprint(dir, true, "asset_FINGERPRINT"); }
87-
expect(fingerprint).toThrowError('Please supply a fingerprint name that is all caps separating words by underscores (i.e. CUSTOM_ASSET_FINGERPRINT).');
94+
expect(fingerprint).toThrowError(formatErrorMessage);
8895
});
8996

9097
it("should validate the file name format.", function() {
9198
var dir = 'config/initializers';
9299
fingerprint = function() { new AssetFingerprint(dir, true, "BAD_VALUE"); }
93-
expect(fingerprint).toThrowError('Please supply a fingerprint name that is all caps separating words by underscores (i.e. CUSTOM_ASSET_FINGERPRINT).');
100+
expect(fingerprint).toThrowError(formatErrorMessage);
94101
});
95102
});
96103

@@ -107,19 +114,6 @@ describe("AssetFingerprint", function() {
107114
});
108115
});
109116

110-
describe("fingerprint name", function() {
111-
beforeEach(function() {
112-
spyOn(fs, "existsSync").and.returnValue(false);
113-
spyOn(fs, "readFileSync").and.returnValue("");
114-
});
115-
116-
it("should not validate when file does not exist.", function () {
117-
var dir = 'config/initializers';
118-
fingerprint = new AssetFingerprint(dir, true, "TEST_FINGERPRINT");
119-
expect(fingerprint.fingerprintName).toEqual("TEST_FINGERPRINT");
120-
});
121-
});
122-
123117
describe("apply", function() {
124118
beforeEach(function() {
125119
spyOn(fs, "writeFileSync");

0 commit comments

Comments
 (0)