Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

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

Open
oscarr-reyes opened this issue Jul 24, 2016 · 1 comment

Comments

@oscarr-reyes
Copy link

oscarr-reyes commented Jul 24, 2016

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
Copy link

wdullaer commented Nov 1, 2016

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants