Skip to content

Commit a3b08e1

Browse files
[CS2] Fix jashkenas#4209: --require for filenames that are invalid identifiers (jashkenas#4658)
* When using --require, check that the variable we’re creating from the required file/module is a valid identifier name before assigning to it; fixes jashkenas#4209 * We don’t need no stinkin’ regex
1 parent 44a27c6 commit a3b08e1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/coffeescript/command.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/command.coffee

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ exports.run = ->
125125

126126
makePrelude = (requires) ->
127127
requires.map (module) ->
128-
[_, name, module] = match if match = module.match(/^(.*)=(.*)$/)
129-
name ||= helpers.baseFileName module, yes, useWinPathSep
130-
"#{name} = require('#{module}')"
128+
[full, name, module] = match if match = module.match(/^(.*)=(.*)$/)
129+
name or= helpers.baseFileName module, yes, useWinPathSep
130+
"global['#{name}'] = require('#{module}')"
131131
.join ';'
132132

133133
# Compile a path, which could be a script or a directory. If a directory

0 commit comments

Comments
 (0)