Skip to content
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
20 changes: 12 additions & 8 deletions packages/core/src/logger/__tests__/transports/github.test.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EOL } from 'node:os';
import { describe, it } from 'node:test';

import { LogLevel } from '../../constants.mjs';
Expand All @@ -24,7 +25,7 @@ describe('github', () => {
t.assert.nthCalledWith(
process.stdout.write,
1,
'::debug::[00:00:00.000] \x1B[34mDEBUG\x1B[39m: Test message\n'
'::debug::[00:00:00.000] \x1B[34mDEBUG\x1B[39m: Test message' + EOL
);
});

Expand All @@ -47,7 +48,7 @@ describe('github', () => {
t.assert.nthCalledWith(
process.stdout.write,
1,
'::notice ::[00:00:00.000] \x1B[32mINFO\x1B[39m: Test message\n'
'::notice ::[00:00:00.000] \x1B[32mINFO\x1B[39m: Test message' + EOL
);
});

Expand All @@ -71,7 +72,7 @@ describe('github', () => {
t.assert.nthCalledWith(
process.stdout.write,
1,
'::error ::[00:00:00.000] \x1B[35mERROR\x1B[39m: Test message\n'
'::error ::[00:00:00.000] \x1B[35mERROR\x1B[39m: Test message' + EOL
);
});

Expand All @@ -95,7 +96,7 @@ describe('github', () => {
t.assert.nthCalledWith(
process.stdout.write,
1,
'::error ::[00:00:00.000] \x1B[31mFATAL\x1B[39m: Test message\n'
'::error ::[00:00:00.000] \x1B[31mFATAL\x1B[39m: Test message' + EOL
);
});

Expand Down Expand Up @@ -128,7 +129,8 @@ describe('github', () => {
t.assert.nthCalledWith(
process.stdout.write,
1,
'::notice file=test.md,line=1,endLine=1::[00:00:00.000] \x1B[32mINFO\x1B[39m: Test message\n'
'::notice file=test.md,line=1,endLine=1::[00:00:00.000] \x1B[32mINFO\x1B[39m: Test message' +
EOL
);
});

Expand Down Expand Up @@ -162,7 +164,8 @@ describe('github', () => {
t.assert.nthCalledWith(
process.stdout.write,
1,
'::notice file=a%2Cb%3Ac%25.md,line=1,endLine=2::[00:00:00.000] \x1B[32mINFO\x1B[39m: 100%25: a, b%0D%0Ac\n'
'::notice file=a%2Cb%3Ac%25.md,line=1,endLine=2::[00:00:00.000] \x1B[32mINFO\x1B[39m: 100%25: a, b%0D%0Ac' +
EOL
);
});

Expand All @@ -186,7 +189,8 @@ describe('github', () => {
t.assert.nthCalledWith(
process.stdout.write,
1,
'::notice ::[00:00:00.000] \x1B[32mINFO\x1B[39m (child1): Test message\n'
'::notice ::[00:00:00.000] \x1B[32mINFO\x1B[39m (child1): Test message' +
EOL
);
});

Expand All @@ -210,7 +214,7 @@ describe('github', () => {
t.assert.nthCalledWith(
process.stdout.write,
1,
'::notice ::[00:00:00.000] INFO: Test message\n'
'::notice ::[00:00:00.000] INFO: Test message' + EOL
);
});
});
18 changes: 12 additions & 6 deletions packages/core/src/utils/loaders.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,20 @@ export const resolveSpecifier = (specifier, filePath) => {
* @returns {Promise<any>} The imported module
*/
export const importFromURL = async url => {
const useJSONAssertion = extname(String(url)) === '.json';
const options =
extname(String(url)) === '.json' ? { with: { type: 'json' } } : {};

const parsed = toParsedURL(url);
let target = toParsedURL(url);

const imported = await import(
parsed ?? pathToFileURL(isAbsolute(url) ? url : join(process.cwd(), url)),
useJSONAssertion ? { with: { type: 'json' } } : {}
);
// An absolute Windows path parses as a URL with its drive letter as the
// protocol, so check for one first
if (typeof url === 'string' && isAbsolute(url)) {
target = pathToFileURL(url);
} else if (!target) {
target = pathToFileURL(join(process.cwd(), String(url)));
}

const imported = await import(target, options);

return imported.default ?? imported;
};
6 changes: 4 additions & 2 deletions packages/react/src/html/utils/__tests__/config.test.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import { describe, it, mock } from 'node:test';
import { fileURLToPath } from 'node:url';
import { fileURLToPath, pathToFileURL } from 'node:url';

import { setConfig } from '@doc-kit/core/utils/configuration/index.mjs';
import { loadMarkdownPlugins } from '@doc-kit/core/utils/markdown/plugins.mjs';
Expand All @@ -12,7 +12,9 @@ const core = createRequire(
fileURLToPath(import.meta.resolve('@doc-kit/core/package.json'))
);

mock.module(core.resolve('shiki/langs'), {
// `mock.module` resolves its specifier as a module URL, so the path
// `core.resolve` returns needs converting (an absolute one, on Windows)
mock.module(pathToFileURL(core.resolve('shiki/langs')).href, {
exports: {
bundledLanguagesInfo: [
{ id: 'javascript', name: 'JavaScript', aliases: ['js'] },
Expand Down
7 changes: 4 additions & 3 deletions packages/typedoc/src/__tests__/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { Application, OptionDefaults, ReflectionKind } from 'typedoc';

import { load } from '../index.mjs';

const FIXTURES = join(import.meta.dirname, 'fixtures');
// TypeDoc's entry point globs only accept posix path separators
const FIXTURES = join(import.meta.dirname, 'fixtures').replaceAll('\\', '/');

/**
* Converts the fixture and writes it as doc-kit Markdown into a temporary
Expand All @@ -22,8 +23,8 @@ const generateFixture = async options => {

const app = await Application.bootstrapWithPlugins({
plugin: [load],
entryPoints: [join(FIXTURES, 'index.ts'), join(FIXTURES, 'utils.ts')],
tsconfig: join(FIXTURES, 'tsconfig.json'),
entryPoints: [`${FIXTURES}/index.ts`, `${FIXTURES}/utils.ts`],
tsconfig: `${FIXTURES}/tsconfig.json`,
readme: 'none',
logLevel: 'Error',
blockTags: [...OptionDefaults.blockTags, '@kind'],
Expand Down
Loading