diff --git a/lib/config.js b/lib/config.js index a1b8c09..67bcf15 100644 --- a/lib/config.js +++ b/lib/config.js @@ -2,7 +2,7 @@ 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'; @@ -10,7 +10,7 @@ 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 */ } @@ -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', }, }, @@ -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); } diff --git a/lib/utils.js b/lib/utils.js index 00ea6ca..e9d9824 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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 || ''; }; diff --git a/package.json b/package.json index 7868e07..208cf9d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/img.test.js b/test/img.test.js index ac96fbb..85ff713 100644 --- a/test/img.test.js +++ b/test/img.test.js @@ -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) => { diff --git a/test/map.test.js b/test/map.test.js index 195837b..cfba059 100644 --- a/test/map.test.js +++ b/test/map.test.js @@ -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(); diff --git a/test/npm.test.js b/test/npm.test.js index e42b0d0..4440bff 100644 --- a/test/npm.test.js +++ b/test/npm.test.js @@ -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) => { diff --git a/test/pkg.test.js b/test/pkg.test.js index be27420..ace489e 100644 --- a/test/pkg.test.js +++ b/test/pkg.test.js @@ -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) => {