Skip to content

Commit 06cd012

Browse files
authored
Merge pull request #13 from derekwheel/dw_no_check
add no-check flag
2 parents 4c8ec5f + 1946970 commit 06cd012

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

src/DenoWorker.spec.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,87 @@ describe('DenoWorker', () => {
277277
});
278278
});
279279

280+
describe('denoNoCheck', async () => {
281+
afterEach(() => {
282+
jest.clearAllMocks();
283+
});
284+
285+
it('should not include the --no-check flag by default', async () => {
286+
const spawnSpy = jest.spyOn(child_process, 'spawn');
287+
288+
worker = new DenoWorker(echoScript);
289+
290+
let resolve: any;
291+
let promise = new Promise((res, rej) => {
292+
resolve = res;
293+
});
294+
worker.onmessage = (e) => {
295+
resolve();
296+
};
297+
298+
worker.postMessage({
299+
type: 'echo',
300+
message: 'Hello',
301+
});
302+
303+
await promise;
304+
305+
const call = spawnSpy.mock.calls[0];
306+
const [_deno, args] = call;
307+
expect(args).not.toContain('--no-check');
308+
});
309+
310+
it('should not include the --no-check flag by when denoNoCheck is false', async () => {
311+
const spawnSpy = jest.spyOn(child_process, 'spawn');
312+
313+
worker = new DenoWorker(echoScript, { denoNoCheck: false });
314+
315+
let resolve: any;
316+
let promise = new Promise((res, rej) => {
317+
resolve = res;
318+
});
319+
worker.onmessage = (e) => {
320+
resolve();
321+
};
322+
323+
worker.postMessage({
324+
type: 'echo',
325+
message: 'Hello',
326+
});
327+
328+
await promise;
329+
330+
const call = spawnSpy.mock.calls[0];
331+
const [_deno, args] = call;
332+
expect(args).not.toContain('--no-check');
333+
});
334+
335+
it('should include the --no-check flag when denoNoCheck is true', async () => {
336+
const spawnSpy = jest.spyOn(child_process, 'spawn');
337+
338+
worker = new DenoWorker(echoScript, { denoNoCheck: true });
339+
340+
let resolve: any;
341+
let promise = new Promise((res, rej) => {
342+
resolve = res;
343+
});
344+
worker.onmessage = (e) => {
345+
resolve();
346+
};
347+
348+
worker.postMessage({
349+
type: 'echo',
350+
message: 'Hello',
351+
});
352+
353+
await promise;
354+
355+
const call = spawnSpy.mock.calls[0];
356+
const [_deno, args] = call;
357+
expect(args).toContain('--no-check');
358+
});
359+
});
360+
280361
describe('denoImportMapPath', async () => {
281362
afterEach(() => {
282363
jest.clearAllMocks();

src/DenoWorker.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ export interface DenoWorkerOptions {
8080
*/
8181
denoCachedOnly: boolean;
8282

83+
/**
84+
* Whether to disable typechecking when starting Deno
85+
*/
86+
denoNoCheck: boolean;
87+
8388
/**
8489
* The permissions that the Deno worker should use.
8590
*/
@@ -183,6 +188,7 @@ export class DenoWorker {
183188
denoImportMapPath: '',
184189
denoLockFilePath: '',
185190
denoCachedOnly: false,
191+
denoNoCheck: false,
186192
},
187193
options || {}
188194
);
@@ -274,6 +280,7 @@ export class DenoWorker {
274280
addOption(runArgs, '--reload', this._options.reload);
275281
addOption(runArgs, '--unstable', this._options.denoUnstable);
276282
addOption(runArgs, '--cached-only', this._options.denoCachedOnly);
283+
addOption(runArgs, '--no-check', this._options.denoNoCheck);
277284

278285
if (this._options.denoV8Flags.length > 0) {
279286
addOption(runArgs, '--v8-flags', this._options.denoV8Flags);

0 commit comments

Comments
 (0)