Skip to content

Fails for files with win32 line endings #17

Closed
@marionebl

Description

@marionebl

Actual behaviour

Files with win32 line endings fail with SyntaxError

echo "\r\nconsole.log('hello')\r\n" > test.js
node -e "require('require-from-string')(fs.readFileSync('./test.js').toString())"

:1
(function (exports, require, module, __filename, __dirname) { \r\nconsole.log('hello')\r\n
                                                              ^

SyntaxError: Invalid or unexpected token
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:537:28)
    at requireFromString (~/node_modules/require-from-string/index.js:28:4)
    at [eval]:1:31
    at ContextifyScript.Script.runInThisContext (vm.js:44:33)
    at Object.runInThisContext (vm.js:116:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:573:30)
    at evalScript (bootstrap_node.js:452:27)

Expected behaviour

Files with win32 do not fail if otherwise syntactially correct.

Related

marionebl/commitlint#270

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions