raml-org / raml-js-parser

(deprecated) A RAML parser based on PyYAML written in CoffeScript and available for use as NodeJs module or in-browser.
195 stars 53 forks source link

Cannot read included files with directory containing spaces on Windows #184

Open oscarr-reyes opened 8 years ago

oscarr-reyes commented 8 years ago

Parser gets an error and no longer works when it tries to load included files in a raml file

for example, the files are placed like this:

c:/Users/LDV Tech/RAML/api.raml c:/Users/LDV Tech/RAML/schemas/tokens.json

raml parser is used like this:

var raml = require("raml-parser");

raml.loadFile("C:/Users/LDV Tech/Documents/RAML/api.raml")
    .then(function(data){
        console.log(data);
    })
    .catch(function(err){
        console.error(err);
        process.exit(1);
    })

The error comes when raml-parser tries to load tokens.json because at some point the directory for this file is processed like this: c:/Users/LDV%20Tech/RAML/schemas/tokens.json. For some reason Documents folder is excluded, and also the user folder encodes the name so windows does not recognize it

if necessary, here is the part of the RAML document that gets this error

#%RAML 0.8
title: test
version: v1
baseUri: https://api.test.com

schemas:
  - tokens: !include schemas/tokens.json

...

OS: Windows 10 Enterprise 64x Nodejs Version: 6.2.0 Package Version: 0.8.18

wdullaer commented 8 years ago

This happens on the mac as well. Somewhere this library html escapes all file paths, regardless of wether they are local or not. When the OS is presented with this html escaped version of the path it cannot find the file

YAMLError: cannot read /Users/wdullaer/Documents/Programming%20Projects/consumer-api/docs-source/wiki/overview.md (Error: ENOENT: no such file or directory, open '/Users/wdullaer/Documents/Programming%20Projects/consumer-api/docs-source/wiki/overview.md')
    at ReadFileContext.callback (/usr/local/lib/node_modules/raml2slate/node_modules/raml-parser/lib/raml.js:66:34)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:365:13)