Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: node_js
node_js:
- '8'
- '12'
- 'lts/*'
- 'node'
after_success:
npm run coverage
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const PROD = process.env.NODE_ENV === 'production';

module.exports = function(opts) {
const PROD = process.env.NODE_ENV === 'production';

if (typeof opts !== 'object') {
throw new TypeError('`options` argument required');
}
Expand Down Expand Up @@ -29,7 +29,8 @@ module.exports = function(opts) {
output = opts.prepend + String(manifest[str] || str);
} else if (typeof manifest[str] === 'object') {
const val = String((manifest[str] && manifest[str][prop]) || str);
output = prop === 'path' ? opts.prepend + val : val;
if (prop === 'path') return opts.prepend + val;
output = PROD ? val : false;
}
} catch (err) {}

Expand Down
5 changes: 1 addition & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ test('returns output of integrity when manifest invoked with old format', t => {

test('returns output of integrity when manifest invoked with new format', t => {
const manifest = path.join(__dirname, 'fixtures', 'rev-manifest.json');
t.is(
manifestRev({ manifest })('script.js', 'integrity'),
'sha256-YEWYfCFP9yc5DAF8K5AtLEyFuKZ1MNw+xQPm8g70LYY='
);
t.is(manifestRev({ manifest })('script.js', 'integrity'), false);
});

test('returns output of integrity when manifest invoked in PROD with old format', t => {
Expand Down