Skip to content

Commit

Permalink
fix: internal module imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Oct 8, 2022
1 parent faeff2c commit 95bf7ac
Show file tree
Hide file tree
Showing 28 changed files with 103 additions and 123 deletions.
2 changes: 1 addition & 1 deletion src/Array.ts
@@ -1,4 +1,4 @@
import { doesExist, isNone, Maybe } from './Maybe';
import { doesExist, isNone, Maybe } from './Maybe.js';

/**
* Merge arguments, which may or may not be arrays, into one return that is definitely an array.
Expand Down
2 changes: 1 addition & 1 deletion src/ArrayMapper.ts
@@ -1,4 +1,4 @@
import { setOrPush } from './Map';
import { setOrPush } from './Map.js';

export interface ArrayMapperOptions {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/Async.ts
@@ -1,5 +1,5 @@
import { TimeoutError } from './error/TimeoutError';
import { PredicateC0 } from './Predicate';
import { TimeoutError } from './error/TimeoutError.js';
import { PredicateC0 } from './Predicate.js';

/**
* Resolve after a set amount of time.
Expand Down
2 changes: 1 addition & 1 deletion src/Buffer.ts
@@ -1,4 +1,4 @@
import { sum } from './Math';
import { sum } from './Math.js';

export type AllowedBufferEncoding = 'ascii' | 'utf-8';

Expand Down
8 changes: 4 additions & 4 deletions src/Child.ts
Expand Up @@ -2,10 +2,10 @@ import { ChildProcessWithoutNullStreams, spawn } from 'child_process';
import { BaseError } from 'noicejs';
import { Writable } from 'stream';

import { encode } from './Buffer';
import { ChildProcessError } from './error/ChildProcessError';
import { NameValuePair } from './Map';
import { doesExist, Maybe } from './Maybe';
import { encode } from './Buffer.js';
import { ChildProcessError } from './error/ChildProcessError.js';
import { NameValuePair } from './Map.js';
import { doesExist, Maybe } from './Maybe.js';

export interface ChildProcessOptions {
cwd: string;
Expand Down
3 changes: 2 additions & 1 deletion src/Logger.ts
@@ -1,5 +1,6 @@
import { ConsoleLogger, Logger, NullLogger } from 'noicejs';
import { isDebug } from './Env';

import { isDebug } from './Env.js';

/**
* Get a test logger. Returns a null logger unless `verbose` is true or run under debug mode.
Expand Down
6 changes: 3 additions & 3 deletions src/Map.ts
@@ -1,6 +1,6 @@
import { mergeArrays, toArray } from './Array';
import { NotFoundError } from './error/NotFoundError';
import { doesExist, isNone, Maybe, mustExist } from './Maybe';
import { mergeArrays, toArray } from './Array.js';
import { NotFoundError } from './error/NotFoundError.js';
import { doesExist, isNone, Maybe, mustExist } from './Maybe.js';

export interface Dict<TVal> {
[key: string]: TVal;
Expand Down
4 changes: 2 additions & 2 deletions src/Maybe.ts
@@ -1,5 +1,5 @@
import { NotFoundError } from './error/NotFoundError';
import { PredicateC1 } from './Predicate';
import { NotFoundError } from './error/NotFoundError.js';
import { PredicateC1 } from './Predicate.js';

/**
* Unset value.
Expand Down
2 changes: 1 addition & 1 deletion src/Optional.ts
@@ -1,5 +1,5 @@
// deprecated alternative names for Maybe
import { isNone, Maybe, None } from '.';
import { isNone, Maybe, None } from './Maybe.js';


/**
Expand Down
4 changes: 2 additions & 2 deletions src/Reflect.ts
@@ -1,5 +1,5 @@
import { InvalidArgumentError } from './error/InvalidArgumentError';
import { doesExist, isNone } from './Maybe';
import { InvalidArgumentError } from './error/InvalidArgumentError.js';
import { doesExist, isNone } from './Maybe.js';

/* eslint-disable-next-line @typescript-eslint/ban-types */
type Reflectable = object;
Expand Down
2 changes: 1 addition & 1 deletion src/app.ts
@@ -1,4 +1,4 @@
import { VERSION_INFO } from './version';
import { VERSION_INFO } from './version.js';

export async function main(argv: Array<string>): Promise<number> {
/* eslint-disable-next-line no-console */
Expand Down
2 changes: 1 addition & 1 deletion src/error/MissingKeyError.ts
@@ -1,4 +1,4 @@
import { NotFoundError } from './NotFoundError';
import { NotFoundError } from './NotFoundError.js';

/**
* Error indicating that a required key did not exist in a map-like.
Expand Down
42 changes: 21 additions & 21 deletions src/index.ts
@@ -1,9 +1,9 @@
export { ChildProcessError } from './error/ChildProcessError';
export { InvalidArgumentError } from './error/InvalidArgumentError';
export { MissingKeyError } from './error/MissingKeyError';
export { NotFoundError } from './error/NotFoundError';
export { NotImplementedError } from './error/NotImplementedError';
export { TimeoutError } from './error/TimeoutError';
export { ChildProcessError } from './error/ChildProcessError.js';
export { InvalidArgumentError } from './error/InvalidArgumentError.js';
export { MissingKeyError } from './error/MissingKeyError.js';
export { NotFoundError } from './error/NotFoundError.js';
export { NotImplementedError } from './error/NotImplementedError.js';
export { TimeoutError } from './error/TimeoutError.js';

export {
mergeArray,
Expand All @@ -15,28 +15,28 @@ export {
filterZip,
lengthOf,
toArray,
} from './Array';
} from './Array.js';
export {
ArrayMapper,
ArrayMapperOptions,
} from './ArrayMapper';
} from './ArrayMapper.js';
export {
defer,
deferUntil,
deferValue,
timeout,
waitFor,
} from './Async';
} from './Async.js';
export {
AllowedBufferEncoding,
concat,
encode,
} from './Buffer';
} from './Buffer.js';
export {
Checklist,
ChecklistMode,
ChecklistOptions,
} from './Checklist';
} from './Checklist.js';
export {
ChildOptions,
ChildResult,
Expand All @@ -45,14 +45,14 @@ export {
waitForChild,
writeInput,
writeValue,
} from './Child';
} from './Child.js';
export {
isDebug
} from './Env';
} from './Env.js';
export {
getTestLogger,
spyLogger,
} from './Logger';
} from './Logger.js';
export {
Dict,
MapLike,
Expand All @@ -68,10 +68,10 @@ export {
pairsToMap,
pushMergeMap,
setOrPush,
} from './Map';
} from './Map.js';
export {
sum,
} from './Math';
} from './Math.js';
export {
Maybe,
None,
Expand All @@ -84,24 +84,24 @@ export {
mustExist,
mustFind,
removeNone,
} from './Maybe';
} from './Maybe.js';
export {
Nil,
Optional,
isNil,
} from './Optional';
} from './Optional.js';
export {
constructorName,
getConstructor,
getMethods,
} from './Reflect';
} from './Reflect.js';
export {
SIGNAL_RELOAD,
SIGNAL_RESET,
SIGNAL_STOP,
signal,
} from './Signal';
} from './Signal.js';
export {
leftPad,
trim,
} from './String';
} from './String.js';
2 changes: 1 addition & 1 deletion test/TestApp.ts
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import sinon from 'sinon';

import { main } from '../src/app';
import { main } from '../src/app.js';

const { spy } = sinon;

Expand Down
8 changes: 4 additions & 4 deletions test/TestLogger.ts
@@ -1,23 +1,23 @@
import { expect } from 'chai';
import { ConsoleLogger, NullLogger } from 'noicejs';

import { getTestLogger, spyLogger } from '../src/Logger';
import { getTestLogger, spyLogger } from '../src/Logger.js';

describe('logger utils', () => {
describe('get test logger helper', () => {
it('should return console logger in verbose mode', () => {
it('should return console logger in verbose mode', async () => {
expect(getTestLogger(true)).to.equal(ConsoleLogger.global);
});

it('should return console logger in debug mode');

it('should return null logger otherwise', () => {
it('should return null logger otherwise', async () => {
expect(getTestLogger()).to.equal(NullLogger.global);
});
});

describe('spy logger helper', () => {
it('should return itself as a child', () => {
it('should return itself as a child', async () => {
const logger = spyLogger({});
expect(logger.child({})).to.equal(logger);
});
Expand Down
18 changes: 9 additions & 9 deletions test/error/TestError.ts
@@ -1,11 +1,11 @@
import { expect } from 'chai';

import { ChildProcessError } from '../../../js-utils/src/error/ChildProcessError';
import { InvalidArgumentError } from '../../../js-utils/src/error/InvalidArgumentError';
import { MissingKeyError } from '../../../js-utils/src/error/MissingKeyError';
import { NotFoundError } from '../../src/error/NotFoundError';
import { NotImplementedError } from '../../../js-utils/src/error/NotImplementedError';
import { TimeoutError } from '../../../js-utils/src/error/TimeoutError';
import { ChildProcessError } from '../../src/error/ChildProcessError.js';
import { InvalidArgumentError } from '../../src/error/InvalidArgumentError.js';
import { MissingKeyError } from '../../src/error/MissingKeyError.js';
import { NotFoundError } from '../../src/error/NotFoundError.js';
import { NotImplementedError } from '../../src/error/NotImplementedError.js';
import { TimeoutError } from '../../src/error/TimeoutError.js';

const errors = [
ChildProcessError,
Expand All @@ -19,18 +19,18 @@ const errors = [
describe('errors', () => {
for (const errorType of errors) {
describe(errorType.name, () => {
it('should have a message', () => {
it('should have a message', async () => {
const err = new errorType();
expect(err.message).to.not.equal('');
});

it('should include nested errors in the stack trace', () => {
it('should include nested errors in the stack trace', async () => {
const inner = new Error('inner error');
const err = new errorType('outer error', inner);
expect(err.stack).to.include('inner', 'inner error message').and.include('outer', 'outer error message');
});

it('should have the nested error', () => {
it('should have the nested error', async () => {
const inner = new Error('inner error');
const err = new errorType('outer error', inner);
expect(err.cause()).to.equal(inner);
Expand Down
22 changes: 0 additions & 22 deletions test/harness.ts

This file was deleted.

6 changes: 3 additions & 3 deletions test/utils/TestArray.ts
Expand Up @@ -4,9 +4,9 @@ import { array, falsy, integer } from 'fast-check';
import { over } from 'mocha-foam';
import sinon from 'sinon';

import { isNone } from '../../src';
import { ensureArray, filterZip, hasItems, isEmpty, lengthOf, mergeArray, toArray } from '../../src/Array';
import { sum } from '../../src/Math';
import { isNone } from '../../src/index.js';
import { ensureArray, filterZip, hasItems, isEmpty, lengthOf, mergeArray, toArray } from '../../src/Array.js';
import { sum } from '../../src/Math.js';

const { match, stub } = sinon;

Expand Down
2 changes: 1 addition & 1 deletion test/utils/TestArrayMapper.ts
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import { ArrayMapper } from '../../src/ArrayMapper';
import { ArrayMapper } from '../../src/ArrayMapper.js';

describe('utils', async () => {
describe('array mapper', async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/utils/TestAsync.ts
@@ -1,7 +1,7 @@
import { expect } from 'chai';

import { defer, deferValue, timeout } from '../../src/Async';
import { TimeoutError } from '../../src/error/TimeoutError';
import { defer, deferValue, timeout } from '../../src/Async.js';
import { TimeoutError } from '../../src/error/TimeoutError.js';

const TEST_DEFER = 10;
const TEST_TOO_LONG = 25;
Expand Down
4 changes: 2 additions & 2 deletions test/utils/TestBuffer.ts
Expand Up @@ -2,8 +2,8 @@ import { expect } from 'chai';
import { array, uint8Array } from 'fast-check';
import { over } from 'mocha-foam';

import { concat, encode } from '../../src/Buffer';
import { sum } from '../../src/Math';
import { concat, encode } from '../../src/Buffer.js';
import { sum } from '../../src/Math.js';

describe('buffer utils', async () => {
describe('concat', async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/utils/TestChecklist.ts
Expand Up @@ -2,7 +2,7 @@ import { expect } from 'chai';
import { array, constant, integer, record } from 'fast-check';
import { over } from 'mocha-foam';

import { Checklist, ChecklistMode } from '../../src/Checklist';
import { Checklist, ChecklistMode } from '../../src/Checklist.js';

const EXISTING_ITEM = 'foo';
const MISSING_ITEM = 'bin';
Expand Down
6 changes: 3 additions & 3 deletions test/utils/TestChild.ts
@@ -1,9 +1,9 @@
import { expect } from 'chai';
import sinon from 'sinon';

import { ChildProcessError } from '../../src';
import { ChildStreams, childResult } from '../../src/Child';
import { Maybe, mustExist } from '../../src/Maybe';
import { ChildProcessError } from '../../src/error/ChildProcessError.js';
import { ChildStreams, childResult } from '../../src/Child.js';
import { Maybe, mustExist } from '../../src/Maybe.js';

const { match, stub } = sinon;

Expand Down

0 comments on commit 95bf7ac

Please sign in to comment.