Skip to content

Commit

Permalink
Make sure wrapper doesn't invalidate strict mode (#29)
Browse files Browse the repository at this point in the history
* make sure wrapper doesn't invalidate strict mode

* refresh Travis matrix
  • Loading branch information
emilbroman-eqt committed Jan 12, 2021
1 parent eccac78 commit 858f01f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
11 changes: 3 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
node_js:
- "4"
- "6"
- "8"
- "10"
- "12"
- "14"
env:
- DEBUG_VERSION=2
- DEBUG_VERSION=3
- DEBUG_VERSION=4
matrix:
exclude:
- node_js: "4"
env: DEBUG_VERSION=4
sudo: false
language: node_js
script:
- npm install --no-save debug@^$DEBUG_VERSION
- npm run ci
after_success:
- npm i -g codecov && codecov -t a62849b5-9006-4dd4-8334-94624d6d8ea2
- npm i -g codecov && codecov -t a62849b5-9006-4dd4-8334-94624d6d8ea2
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ function override (script) {
}
return req(s)
}, req)
}(require));
`.replace(/\n/g, ';').replace(/\s+/g, ' ').replace(/;+/g, ';')
var tail = '\n});'
}(require))
return (function(){
`.trim().replace(/\n/g, ';').replace(/\s+/g, ' ').replace(/;+/g, ';')
var tail = '\n}).call(this);})'

return head + script + tail
}
6 changes: 6 additions & 0 deletions test/fixtures/strict-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'

eval('var test = 123')

// This will evaluate to `true` if strict mode is enabled
module.exports = typeof test === 'undefined'
5 changes: 5 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,8 @@ test('supports extend method', (t) => {
debug('ns1').extend('ns2', ';')('test')
stream.end()
})

test('does not invalidate strict mode', (t) => {
t.is(require('./fixtures/strict-mode'), true)
t.end()
})

0 comments on commit 858f01f

Please sign in to comment.