Skip to content

Fix CI tests (no Sauce Labs) #2

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/CI-CD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- macos-latest
- windows-latest
node:
- 14
- 17
- lts/*
- current

Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = karmaConfig({
firefox: host.ci ? host.os.linux : true,
// TODO these were disabled as unstable. should we remove saucelabs or what?
// safari: host.ci ? host.os.linux : host.os.mac, // SauceLabs in CI
edge: host.ci ? host.os.linux : host.os.windows, // SauceLabs in CI
edge: host.ci ? false : host.os.windows, // SauceLabs in CI
// ie: host.ci ? host.os.windows : false, // IE needs to run by itself, due to Babel transforms
},
});
2 changes: 1 addition & 1 deletion lib/refs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { ono } = require("@jsdevtools/ono");
const $Ref = require("./ref");
const url = require("./util/url");

const isWindows = /^win/.test(globalThis.process?.platform);
const isWindows = /^win/.test(globalThis.process ? globalThis.process.platform : undefined);
const getPathFromOs = filePath => isWindows ? filePath.replace(/\\/g, "/") : filePath;

module.exports = $Refs;
Expand Down
18 changes: 9 additions & 9 deletions lib/resolvers/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = {
* @param {object} file - An object containing information about the referenced file
* @param {string} file.url - The full URL of the referenced file
* @param {string} file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
* @returns {Promise<string>}
* @returns {Promise<Buffer>}
*/
read (file) {
let u = url.parse(file.url);
Expand All @@ -89,7 +89,7 @@ module.exports = {
* @param {object} httpOptions - The `options.resolve.http` object
* @param {number} [redirects] - The redirect URLs that have already been followed
*
* @returns {Promise<string>}
* @returns {Promise<Buffer>}
* The promise resolves with the raw downloaded data, or rejects if there is an HTTP error.
*/
function download (u, httpOptions, redirects) {
Expand All @@ -99,25 +99,25 @@ function download (u, httpOptions, redirects) {

return get(u, httpOptions)
.then((res) => {
if (res.statusCode >= 400) {
throw ono({ status: res.statusCode }, `HTTP ERROR ${res.statusCode}`);
if (res.status >= 400) {
throw ono({ status: res.statusCode }, `HTTP ERROR ${res.status}`);
}
else if (res.statusCode >= 300) {
else if (res.status >= 300) {
if (redirects.length > httpOptions.redirects) {
throw new ResolverError(ono({ status: res.statusCode },
throw new ResolverError(ono({ status: res.status },
`Error downloading ${redirects[0]}. \nToo many redirects: \n ${redirects.join(" \n ")}`));
}
else if (!res.headers.location) {
throw ono({ status: res.statusCode }, `HTTP ${res.statusCode} redirect with no location header`);
throw ono({ status: res.status }, `HTTP ${res.status} redirect with no location header`);
}
else {
// console.log('HTTP %d redirect %s -> %s', res.statusCode, u.href, res.headers.location);
// console.log('HTTP %d redirect %s -> %s', res.status, u.href, res.headers.location);
let redirectTo = url.resolve(u, res.headers.location);
return download(redirectTo, httpOptions, redirects);
}
}
else {
return res.text();
return res.body ? res.arrayBuffer().then(buf => Buffer.from(buf)) : Buffer.alloc(0);
}
})
.catch((err) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/util/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const nodePath = require("path");
const projectDir = nodePath.resolve(__dirname, "..", "..");

let isWindows = /^win/.test(globalThis.process?.platform),
let isWindows = /^win/.test(globalThis.process ? globalThis.process.platform : undefined),
forwardSlashPattern = /\//g,
protocolPattern = /^(\w{2,}):\/\//i,
url = module.exports,
Expand Down
Loading