Skip to content

Issues with transform exercise on Windows #28

@marcinwasilewski

Description

@marcinwasilewski

I tried to run the official solution for transforms exercise which in my case should look as follows:

  var fs = require('fs');                                                                                                                           
  var txt = fs.readFileSync('C:\Users\marcin\AppData\Roaming\npm\node_modules\browserify-adventure\problems\using_transforms\wake.txt', 'utf8');    
  var sprintf = require('sprintf');                                                                                                                 
                                                                                                                                                    
  var lines = txt.split('\n');                                                                                                                      
  lines.forEach(function (line, index) {                                                                                                            
      if (index % 5 === 0) {                                                                                                                        
          console.log(sprintf('%3d %s', index, line));                                                                                              
      }                                                                                                                                             
      else {                                                                                                                                        
          console.log('    ' + line);                                                                                                               
      }                                                                                                                                             
  });       

That however produces a SyntaxError:

TAP version 13
SyntaxError: Bad character escape sequence (2:28) while parsing file: C:\Users\marcin\node-stuff\browserify-adventure\main.js
    at Parser.pp.raise (C:\Users\marcin\node-stuff\browserify-adventure\node_modules\acorn\dist\acorn.js:1745:13)
    at Parser.pp.readHexChar (C:\Users\marcin\node-stuff\browserify-adventure\node_modules\acorn\dist\acorn.js:3762:24)
    at Parser.pp.readCodePoint (C:\Users\marcin\node-stuff\browserify-adventure\node_modules\acorn\dist\acorn.js:3631:17)
    at Parser.pp.readEscapedChar (C:\Users\marcin\node-stuff\browserify-adventure\node_modules\acorn\dist\acorn.js:3733:39)
    at Parser.pp.readString (C:\Users\marcin\node-stuff\browserify-adventure\node_modules\acorn\dist\acorn.js:3653:19)
    at Parser.pp.getTokenFromCode (C:\Users\marcin\node-stuff\browserify-adventure\node_modules\acorn\dist\acorn.js:3446:19)
    at Parser.pp.readToken (C:\Users\marcin\node-stuff\browserify-adventure\node_modules\acorn\dist\acorn.js:3189:15)
    at Parser.pp.nextToken (C:\Users\marcin\node-stuff\browserify-adventure\node_modules\acorn\dist\acorn.js:3181:71)
    at Parser.pp.next (C:\Users\marcin\node-stuff\browserify-adventure\node_modules\acorn\dist\acorn.js:3130:8)
    at Parser.pp.eat (C:\Users\marcin\node-stuff\browserify-adventure\node_modules\acorn\dist\acorn.js:2201:10)
# (anonymous)

None of the lines are marked as correct either:

not ok 1 should be equal                                                                   
  ---                                                                                      
    operator: equal                                                                        
    expected:                                                                              
      '0 Be that as it may, but for that light phantastic of his gnose\'s glow as it'      
    actual:                                                                                
      ''                                                                                   
  ...                                                                                      
not ok 2 should be equal                                                                   
  ---                                                                                      
    operator: equal                                                                        
    expected:                                                                              
      '    slid lucifericiously within an inch of its page (he touch at its from time'     
    actual:                                                                                
      undefined                                                                            
  ...         

(...)                                                                             

For some reason saving the file wake.txt to a local directory and changing the path to relative in readFileSync solves the issue.

var txt = fs.readFileSync('wake.txt', 'utf8');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions