Skip to content

Commit

Permalink
Latest debug attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Sturgeon committed Apr 16, 2018
1 parent 1d61d6c commit b1599ae
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,17 @@ function readFileAsync(filename, encoding) {
}

const fetchUrl = async (url) => {
console.log('got here', url);
console.log('inside fetchUrl', url);

fetch(url).then(data => {
console.log('data', data)
}, err => {
throw 'WHAT THE FUCL'
console.log('err', err)
});

console.log('did that happen?');

const response = await fetch(url).catch(err => { throw err });
let response;
try {
console.log('about to hit await fetch')
response = await fetch(url).catch(err => { console.log('fetch() failed!', err) });
console.log('finished with fetch')
} catch (err) {
console.log('caught err', err)
}
console.log('got a response', response)

if (response.ok) {
try {
Expand Down Expand Up @@ -96,12 +95,22 @@ const readOrError = async (file, options = {}) => {
}

const recursivelyLoadRuleFiles = async (file, loadedFiles, options) => {
console.log('inside recursivelyLoadRuleFiles', file, loadedFiles, options);
const { verbose } = options;
if (verbose > 1) console.log('GET ' + file);

let data;
if (file && file.startsWith('http')) {
data = await fetchUrl(file);
try {
console.log('calling fetchUrl');
data = await fetchUrl(file);
console.log('just called fetchUrl, got data:', data);

} catch (err) {
console.log('what soo confused', err);
}

console.log('please work')
}
else {
const ruleFile = path.join(__dirname, '../rules/' + file + '.json');
Expand All @@ -121,7 +130,7 @@ const recursivelyLoadRuleFiles = async (file, loadedFiles, options) => {
}

// Tell the linter about these new rules
linter.createNewRules(rules);
linter.createNewRules(data.rules);

return loadedFiles;
}
Expand Down

0 comments on commit b1599ae

Please sign in to comment.