Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ed74896
deps: update V8 to 7.5.288.22
refack May 28, 2019
d661500
build: reset embedder string to "-node.0"
refack May 28, 2019
e3cd79e
src: update NODE_MODULE_VERSION to 74
refack May 28, 2019
417c18e
build,v8: sync V8 gypfiles with 7.5
refack Mar 29, 2019
317b712
tools,gyp: introduce MSVS 2019
refack May 22, 2019
a74c46b
deps: V8: fix filename manipulation for Windows
refack Mar 31, 2019
e378e7d
deps: V8: un-cherry-pick bd019bd
refack Mar 27, 2019
115c9be
deps: V8: silence irrelevant warning
targos Mar 27, 2019
0859870
deps: V8: update postmortem metadata generation script
cjihrig Mar 28, 2019
cdd4439
deps: V8: cherry-pick cca9ae3c9a
bmeurer May 15, 2019
4badd3e
deps: V8: backport f89e555
targos May 23, 2019
9457fab
deps: V8: patch register-arm64.h
refack May 22, 2019
a6e7d21
deps: V8: forward declaration of `Rtl*FunctionTable`
refack May 22, 2019
c81bb22
deps: V8: use ATOMIC_VAR_INIT instead of std::atomic_init
refack May 23, 2019
0df8f53
deps: V8: template explicit instantiation for GCC-8
refack May 23, 2019
6797610
deps: V8: workaround for MSVC 14.20 optimizer bug
refack May 17, 2019
ad40a03
deps: V8: fix BUILDING_V8_SHARED issues
refack May 26, 2019
951318f
deps: V8: backport 3a75c1f
refack May 28, 2019
f73d5c2
deps: bump minimum icu version to 64
targos Apr 24, 2019
abfc8ae
test: drain platform before unregistering isolate
refack May 25, 2019
702331b
lib: no need to strip BOM or shebang for scripts
refack May 27, 2019
2983eac
test: fail `test-worker-prof` on internal timeout
refack Jun 1, 2019
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
Prev Previous commit
Next Next commit
lib: no need to strip BOM or shebang for scripts
PR-URL: #27375
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
refack committed Jun 1, 2019
commit 702331be906fe58e0ef66c7b31c7d2aeb3af3421
6 changes: 1 addition & 5 deletions lib/internal/main/check_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ const {

const { pathToFileURL } = require('url');

const {
stripShebangOrBOM,
} = require('internal/modules/cjs/helpers');

const {
Module: {
_resolveFilename: resolveCJSModuleName,
Expand Down Expand Up @@ -68,5 +64,5 @@ function checkSyntax(source, filename) {
}
}

wrapSafe(filename, stripShebangOrBOM(source));
wrapSafe(filename, source);
}
33 changes: 0 additions & 33 deletions lib/internal/modules/cjs/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,37 +52,6 @@ function stripBOM(content) {
return content;
}

/**
* Find end of shebang line and slice it off
*/
function stripShebang(content) {
// Remove shebang
if (content.charAt(0) === '#' && content.charAt(1) === '!') {
// Find end of shebang line and slice it off
let index = content.indexOf('\n', 2);
if (index === -1)
return '';
if (content.charAt(index - 1) === '\r')
index--;
// Note that this actually includes the newline character(s) in the
// new output. This duplicates the behavior of the regular expression
// that was previously used to replace the shebang line.
content = content.slice(index);
}
return content;
}

// Strip either the shebang or UTF BOM of a file.
// Note that this only processes one. If both occur in
// either order, the one that comes second is not
// significant.
function stripShebangOrBOM(content) {
if (content.charCodeAt(0) === 0xFEFF) {
return content.slice(1);
}
return stripShebang(content);
}

const builtinLibs = [
'assert', 'async_hooks', 'buffer', 'child_process', 'cluster', 'crypto',
'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'http2', 'https', 'net',
Expand Down Expand Up @@ -148,6 +117,4 @@ module.exports = {
makeRequireFunction,
normalizeReferrerURL,
stripBOM,
stripShebang,
stripShebangOrBOM,
};
4 changes: 0 additions & 4 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const {
makeRequireFunction,
normalizeReferrerURL,
stripBOM,
stripShebangOrBOM,
} = require('internal/modules/cjs/helpers');
const { getOptionValue } = require('internal/options');
const preserveSymlinks = getOptionValue('--preserve-symlinks');
Expand Down Expand Up @@ -745,9 +744,6 @@ Module.prototype._compile = function(content, filename) {
manifest.assertIntegrity(moduleURL, content);
}

// Strip after manifest integrity check
content = stripShebangOrBOM(content);

const compiledWrapper = wrapSafe(filename, content);

var inspectorWrapper = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!shebang
#!shebang
module.exports = 42;
14 changes: 0 additions & 14 deletions test/parallel/test-internal-modules-strip-shebang.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/sequential/test-module-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ assert.strictEqual(require('../fixtures/utf8-bom.json'), 42);
// Loading files with BOM + shebang.
// See https://github.com/nodejs/node/issues/27767
assert.throws(() => {
require('../fixtures/utf8-bom-shebang.js');
require('../fixtures/utf8-bom-shebang-shebang.js');
}, { name: 'SyntaxError' });
assert.strictEqual(require('../fixtures/utf8-shebang-bom.js'), 42);

Expand Down