Skip to content

Commit

Permalink
fix: windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Aug 15, 2024
1 parent 74cca93 commit 78f555a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest, windows-latest]
node-version: [18, 20]
runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion lib/classes/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Asset = class Asset {
this._size = -1;

this._integrity = "";
this._pathname = path.join("/", pathname);
this._pathname = path.join("/", pathname).replace(/\\/g, "/");
this._version = version;
this._name = name;
this._org = org;
Expand Down
12 changes: 6 additions & 6 deletions lib/sinks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class SinkTest extends Sink {
}

set(filePath, payload) {
const pathname = path.join(this._rootPath, filePath);
const pathname = path.join(this._rootPath, filePath).replace(/\\/g, "/");
const mimeType = mime.getType(pathname) || "application/octet-stream";

let entry;
Expand All @@ -56,7 +56,7 @@ export default class SinkTest extends Sink {
}

get(filePath) {
const pathname = path.join(this._rootPath, filePath);
const pathname = path.join(this._rootPath, filePath).replace(/\\/g, "/");
if (this._state.has(pathname)) {
const entry = this._state.get(pathname);
return entry.payload.join("");
Expand Down Expand Up @@ -110,7 +110,7 @@ export default class SinkTest extends Sink {
return;
}

const pathname = path.join(this._rootPath, filePath);
const pathname = path.join(this._rootPath, filePath).replace(/\\/g, "/");

if (pathname.indexOf(this._rootPath) !== 0) {
this._counter.inc({ labels: { operation } });
Expand Down Expand Up @@ -178,7 +178,7 @@ export default class SinkTest extends Sink {
return;
}

const pathname = path.join(this._rootPath, filePath);
const pathname = path.join(this._rootPath, filePath).replace(/\\/g, "/");

if (pathname.indexOf(this._rootPath) !== 0) {
this._counter.inc({ labels: { operation } });
Expand Down Expand Up @@ -228,7 +228,7 @@ export default class SinkTest extends Sink {
return;
}

const pathname = path.join(this._rootPath, filePath);
const pathname = path.join(this._rootPath, filePath).replace(/\\/g, "/");

if (pathname.indexOf(this._rootPath) !== 0) {
this._counter.inc({ labels: { operation } });
Expand Down Expand Up @@ -267,7 +267,7 @@ export default class SinkTest extends Sink {
return;
}

const pathname = path.join(this._rootPath, filePath);
const pathname = path.join(this._rootPath, filePath).replace(/\\/g, "/");

if (pathname.indexOf(this._rootPath) !== 0) {
this._counter.inc({ labels: { operation } });
Expand Down
15 changes: 10 additions & 5 deletions lib/utils/path-builders-uri.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import globals from "./globals.js";
// Build URL pathname to a package log file

const createURIPathToPkgLog = ({ type = "", name = "", version = "" } = {}) =>
path.join(globals.ROOT, type, name, version);
path.join(globals.ROOT, type, name, version).replace(/\\/g, "/");

// Build URL pathname to an asset in a package

Expand All @@ -13,17 +13,21 @@ const createURIPathToAsset = ({
name = "",
version = "",
asset = "",
} = {}) => path.join(globals.ROOT, type, name, version, asset);
} = {}) =>
path.join(globals.ROOT, type, name, version, asset).replace(/\\/g, "/");

// Build URL pathname to an import map

const createURIPathToImportMap = ({ name = "", version = "" } = {}) =>
path.join(globals.ROOT, globals.BASE_IMPORT_MAPS, name, version);
path
.join(globals.ROOT, globals.BASE_IMPORT_MAPS, name, version)
.replace(/\\/g, "/")
.replace(/\\/g, "/");

// Build URL pathname to an alias source

const createURIToAlias = ({ type = "", name = "", alias = "" } = {}) =>
path.join(globals.ROOT, type, name, `v${alias}`);
path.join(globals.ROOT, type, name, `v${alias}`).replace(/\\/g, "/");

// Build URL pathname to an alias target destination

Expand All @@ -32,7 +36,8 @@ const createURIToTargetOfAlias = ({
name = "",
version = "",
extra = "",
} = {}) => path.join(globals.ROOT, type, name, version, extra);
} = {}) =>
path.join(globals.ROOT, type, name, version, extra).replace(/\\/g, "/");

export {
createURIPathToPkgLog,
Expand Down

0 comments on commit 78f555a

Please sign in to comment.