-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(shebang): support shebang in in files (#2510)
Support shebang (i.e. `#!/usr/bin/env node`) in javascript files.
- Loading branch information
Showing
8 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#! /usr/bin/env node | ||
module.exports.add = function(num1, num2) { | ||
return num1 + num2; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /usr/bin/env node | ||
|
||
console.log('test'); |
61 changes: 61 additions & 0 deletions
61
packages/instrumenter/testResources/instrumenter/shebang.js.out.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`instrumenter integration should be able to instrument js files with a shebang in them 1`] = ` | ||
"#! /usr/bin/env node | ||
function stryNS_9fa48() { | ||
var g = new Function(\\"return this\\")(); | ||
var ns = g.__stryker__ || (g.__stryker__ = {}); | ||
if (ns.activeMutant === undefined && g.process && g.process.env && g.process.env.__STRYKER_ACTIVE_MUTANT__) { | ||
ns.activeMutant = Number(g.process.env.__STRYKER_ACTIVE_MUTANT__); | ||
} | ||
function retrieveNS() { | ||
return ns; | ||
} | ||
stryNS_9fa48 = retrieveNS; | ||
return retrieveNS(); | ||
} | ||
stryNS_9fa48(); | ||
function stryCov_9fa48() { | ||
var ns = stryNS_9fa48(); | ||
var cov = ns.mutantCoverage || (ns.mutantCoverage = { | ||
static: {}, | ||
perTest: {} | ||
}); | ||
function cover() { | ||
var c = cov.static; | ||
if (ns.currentTestId) { | ||
c = cov.perTest[ns.currentTestId] = cov.perTest[ns.currentTestId] || {}; | ||
} | ||
var a = arguments; | ||
for (var i = 0; i < a.length; i++) { | ||
c[a[i]] = (c[a[i]] || 0) + 1; | ||
} | ||
} | ||
stryCov_9fa48 = cover; | ||
cover.apply(null, arguments); | ||
} | ||
function stryMutAct_9fa48(id) { | ||
var ns = stryNS_9fa48(); | ||
function isActive(id) { | ||
return ns.activeMutant === id; | ||
} | ||
stryMutAct_9fa48 = isActive; | ||
return isActive(id); | ||
} | ||
console.log(stryMutAct_9fa48(0) ? \\"\\" : (stryCov_9fa48(0), 'test'));" | ||
`; |