File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ module.exports = {
1414 CHAR_COLON : 58 , /* : */
1515 CHAR_QUESTION_MARK : 63 , /* ? */
1616 CHAR_UNDERSCORE : 95 , /* _ */
17+ CHAR_LINE_FEED : 10 , /* \n */
18+ CHAR_CARRIAGE_RETURN : 13 , /* \r */
19+ CHAR_EXCLAMATION_MARK : 33 , /* ! */
20+ CHAR_HASH : 35 , /* # */
1721
1822 // Digits
1923 CHAR_0 : 48 , /* 0 */
Original file line number Diff line number Diff line change 22
33const errors = require ( 'internal/errors' ) ;
44
5+ const {
6+ CHAR_LINE_FEED ,
7+ CHAR_CARRIAGE_RETURN ,
8+ CHAR_EXCLAMATION_MARK ,
9+ CHAR_HASH ,
10+ } = require ( 'internal/constants' ) ;
11+
512// Invoke with makeRequireFunction(module) where |module| is the Module object
613// to use as the context for the require() function.
714function makeRequireFunction ( mod ) {
@@ -65,8 +72,8 @@ function stripShebang(content) {
6572 // Remove shebang
6673 var contLen = content . length ;
6774 if ( contLen >= 2 ) {
68- if ( content . charCodeAt ( 0 ) === 35 /*#*/ &&
69- content . charCodeAt ( 1 ) === 33 /*!*/ ) {
75+ if ( content . charCodeAt ( 0 ) === CHAR_HASH &&
76+ content . charCodeAt ( 1 ) === CHAR_EXCLAMATION_MARK ) {
7077 if ( contLen === 2 ) {
7178 // Exact match
7279 content = '' ;
@@ -75,7 +82,7 @@ function stripShebang(content) {
7582 var i = 2 ;
7683 for ( ; i < contLen ; ++ i ) {
7784 var code = content . charCodeAt ( i ) ;
78- if ( code === 10 /*\n*/ || code === 13 /*\r*/ )
85+ if ( code === CHAR_LINE_FEED || code === CHAR_CARRIAGE_RETURN )
7986 break ;
8087 }
8188 if ( i === contLen )
You can’t perform that action at this time.
0 commit comments