Skip to content

Commit

Permalink
fix: add support for windows hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Aug 15, 2024
1 parent 2a28fd8 commit 96e4355
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 23 deletions.
8 changes: 4 additions & 4 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import convict from 'convict';
import yaml from 'js-yaml';
import pino from 'pino';
import path, { join } from 'path';
import path from 'path';
import fs from 'fs';
import os from 'os';

const CWD = process.cwd();

let pack = {};
try {
pack = JSON.parse(fs.readFileSync(join(CWD, 'package.json'), 'utf-8'));
pack = JSON.parse(fs.readFileSync(path.join(CWD, 'package.json'), 'utf-8'));
} catch (error) {
/* empty */
}
Expand Down Expand Up @@ -148,7 +148,7 @@ const conf = convict({
path: {
doc: 'Absolute path to store files in when using the "fs" sink',
format: String,
default: path.join(os.tmpdir(), '/eik'),
default: path.join(os.tmpdir(), 'eik'),
env: 'SINK_PATH',
},
},
Expand All @@ -163,7 +163,7 @@ const logger = pino({
});

try {
conf.loadFile(path.join(CWD, `/config/${env}.yaml`));
conf.loadFile(path.join(CWD, 'config', `${env}.yaml`));
} catch (error) {
logger.error(error);
}
Expand Down
8 changes: 6 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import path from 'path';

function doJoin(a, b) {
return path.join(a, b).replace(/\\/g, '/');
}

const sanitizeExtras = (extras, version) => {
if (version && extras) {
return path.join(version, extras);
return doJoin(version, extras);
}
return extras || '';
};

const sanitizeName = (scope, name) => {
if (scope && name) {
return path.join(scope, name);
return doJoin(scope, name);
}
return scope || '';
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@eik/core": "1.4.0",
"@eik/sink": "1.2.5",
"@eik/sink-file-system": "1.0.1",
"@eik/sink-memory": "1.1.1",
"@eik/sink-memory": "1.1.2",
"@fastify/compress": "6.5.0",
"@fastify/cors": "8.5.0",
"@fastify/jwt": "7.2.4",
Expand Down
8 changes: 4 additions & 4 deletions test/img.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import FormData from 'form-data';
import Fastify from 'fastify';
import fetch from 'node-fetch';
import path from 'path';
import path from 'node:path';
import tap from 'tap';
import url from 'url';
import fs from 'fs';
import url from 'node:url';
import fs from 'node:fs';

import Sink from '@eik/core/lib/sinks/test.js';
import Server from '../lib/main.js';

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

const FIXTURE_PKG = path.resolve(__dirname, '../fixtures/archive.tgz');
const FIXTURE_PKG = path.resolve(__dirname, '..', 'fixtures', 'archive.tgz');

// Ignore the timestamp for "created" field in the snapshots
tap.cleanSnapshot = (s) => {
Expand Down
13 changes: 9 additions & 4 deletions test/map.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import FormData from 'form-data';
import Fastify from 'fastify';
import fetch from 'node-fetch';
import path from 'path';
import path from 'node:path';
import tap from 'tap';
import url from 'url';
import fs from 'fs';
import url from 'node:url';
import fs from 'node:fs';

import Sink from '@eik/core/lib/sinks/test.js';
import Server from '../lib/main.js';

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

const FIXTURE_MAP = path.resolve(__dirname, '../fixtures/import-map.json');
const FIXTURE_MAP = path.resolve(
__dirname,
'..',
'fixtures',
'import-map.json',
);

tap.beforeEach(async (t) => {
const sink = new Sink();
Expand Down
8 changes: 4 additions & 4 deletions test/npm.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import FormData from 'form-data';
import Fastify from 'fastify';
import fetch from 'node-fetch';
import path from 'path';
import path from 'node:path';
import tap from 'tap';
import url from 'url';
import fs from 'fs';
import url from 'node:url';
import fs from 'node:fs';

import Sink from '@eik/core/lib/sinks/test.js';
import Server from '../lib/main.js';

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

const FIXTURE_PKG = path.resolve(__dirname, '../fixtures/archive.tgz');
const FIXTURE_PKG = path.resolve(__dirname, '..', 'fixtures', 'archive.tgz');

// Ignore the timestamp for "created" field in the snapshots
tap.cleanSnapshot = (s) => {
Expand Down
8 changes: 4 additions & 4 deletions test/pkg.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import FormData from 'form-data';
import Fastify from 'fastify';
import fetch from 'node-fetch';
import path from 'path';
import path from 'node:path';
import tap from 'tap';
import url from 'url';
import fs from 'fs';
import url from 'node:url';
import fs from 'node:fs';

import Sink from '@eik/core/lib/sinks/test.js';
import Server from '../lib/main.js';

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

const FIXTURE_PKG = path.resolve(__dirname, '../fixtures/archive.tgz');
const FIXTURE_PKG = path.resolve(__dirname, '..', 'fixtures', 'archive.tgz');

// Ignore the timestamp for "created" field in the snapshots
tap.cleanSnapshot = (s) => {
Expand Down

0 comments on commit 96e4355

Please sign in to comment.