Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure wrapper doesn't invalidate strict mode #29

Merged
merged 2 commits into from
Jan 12, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()
})