Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue/61: split('/n') does not work on Windows #89

Merged
merged 3 commits into from
May 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions loader.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"use strict";

const os = require('os');
const gql = require('./src');

// Takes `source` (the source GraphQL query string)
// and `doc` (the parsed GraphQL document) and tacks on
// the imported definitions.
function expandImports(source, doc) {
const lines = source.split('\n');
const lines = source.split(os.EOL);
let outputCode = `
var names = {};
function unique(defs) {
Expand All @@ -30,7 +31,7 @@ function expandImports(source, doc) {
const importFile = line.slice(1).split(' ')[1];
const parseDocument = `require(${importFile})`;
const appendDef = `doc.definitions = doc.definitions.concat(unique(${parseDocument}.definitions));`;
outputCode += appendDef + "\n";
outputCode += appendDef + os.EOL;
}
return (line.length !== 0 && line[0] !== '#');
});
Expand All @@ -47,5 +48,5 @@ module.exports = function(source) {
`;
const importOutputCode = expandImports(source, doc);

return outputCode + "\n" + importOutputCode + "\n" + `module.exports = doc;`;
return outputCode + os.EOL + importOutputCode + os.EOL + `module.exports = doc;`;
};