Skip to content

Commit 6e68705

Browse files
committed
Use esm with mocha
1 parent 245b5f7 commit 6e68705

11 files changed

Lines changed: 24 additions & 16 deletions

File tree

bin/latch renamed to bin/latch.cjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
* @module bin/latch
99
* @private
1010
*/
11-
1211
const {spawn} = require('child_process');
1312

14-
const args = ['--exit', '--color', '--reporter', `${require('path').dirname(__dirname)}/dist/cjs/framework/MochaReporter.cjs`, '--require', 'ts-node/register', '--ui', 'bdd', ].concat(process.argv.slice(2));
13+
const args = ['--exit', '--color', '--reporter', `${require('path').dirname(__dirname)}/dist/cjs/framework/MochaReporter.cjs`, '--loader=ts-node/esm', '--experimental-specifier-resolution=node', '--require', 'ts-node/register', '--ui', 'bdd' ].concat(process.argv.slice(2));
1514
const proc = spawn('mocha', args, {
1615
stdio: 'inherit'
1716
});
@@ -45,4 +44,4 @@ process.on('SIGINT', () => {
4544
proc.kill('SIGTERM');
4645
}
4746
}
48-
});
47+
});

mocharc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"node-option": [
3+
"experimental-specifier-resolution=node",
4+
"loader=ts-node/esm"
5+
]
6+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "latch",
33
"description": "A testing language for constraint environments",
44
"version": "0.0.1",
5-
"type": "commonjs",
5+
"type": "module",
66
"exports": {
77
"types": "./dist/types/index.d.ts",
88
"require": "./dist/cjs/index.cjs"
@@ -14,7 +14,7 @@
1414
"bin"
1515
],
1616
"bin": {
17-
"latch": "bin/latch"
17+
"latch": "bin/latch.cjs"
1818
},
1919
"scripts": {
2020
"clean": "rm -rf dist",

src/framework/Testee.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {TestScenario} from './scenario/TestScenario';
1313
import {TestbedSpecification} from '../testbeds/TestbedSpecification';
1414
import {Scheduler} from './Scheduler';
1515
import {CompileOutput, CompilerFactory} from '../manage/Compiler';
16-
import {WABT} from '../util/deps';
16+
import {WABT} from '../util/env';
1717

1818
function timeout<T>(label: string, time: number, promise: Promise<T>): Promise<T> {
1919
return Promise.race([promise, new Promise<T>((resolve, reject) => setTimeout(() => reject(`timeout when ${label}`), time))]);

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Framework} from './framework/Framework';
22

33
export * from './manage/Compiler';
44
export * from './manage/Uploader';
5-
export * from './util/deps';
5+
export * from './util/env';
66
export * from './framework/scenario/Actions';
77
export * from './framework/Testee';
88
export * from './framework/Framework';

src/sourcemap/SourceMapFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {getFileExtension} from '../util/util';
22
import {CompileOutput, CompilerFactory} from '../manage/Compiler';
33
import {AsScriptMapper, WatMapper} from './SourceMapper';
4-
import {WABT} from '../util/deps';
4+
import {WABT} from '../util/env';
55
import {SourceMap} from './SourceMap';
66
import * as path from 'path';
77

src/testbeds/TestbedFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Testbed} from './Testbed';
2-
import {ARDUINO, EMULATOR, WABT} from '../util/deps';
2+
import {ARDUINO, EMULATOR, WABT} from '../util/env';
33
import {CompileOutput, CompilerFactory} from '../manage/Compiler';
44
import {Emulator} from './Emulator';
55
import {UploaderFactory} from '../manage/Uploader';

src/util/deps.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/util/env.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {homedir} from 'os';
2+
3+
export const WABT: string = process.env.WABT ?? '/home/tom/Documents/TOPL/plugin/WABT/build/';
4+
5+
export const EMULATOR: string = process.env.EMULATOR ?? `${homedir()}/Arduino/libraries/WARDuino/build-emu/wdcli`;
6+
7+
export const ARDUINO: string = `${homedir()}/Arduino/libraries/WARDuino/platforms/Arduino/`;

test/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ArduinoSpecification, EmulatorSpecification, Expected, Framework, Invoker, Kind, Message, Step, WASM} from '../src';
1+
import {ArduinoSpecification, EmulatorSpecification, Expected, Framework, Invoker, Kind, Message, Step, WASM} from '../src/index';
22
import dump = Message.dump;
33
import stepOver = Message.stepOver;
44

0 commit comments

Comments
 (0)