Skip to content

Commit

Permalink
fix(cli): handle Windows paths in npm run test:cli (NangoHQ#2312)
Browse files Browse the repository at this point in the history
some tests failed on Windows
  • Loading branch information
bburns committed Jun 27, 2024
1 parent 2f8cbd4 commit 578f270
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/cli/lib/services/model.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ export function fieldToTypescript({ field }: { field: NangoModelField }): string
*/
export function generateSDKTypes() {
const filePath = resolve('@nangohq/shared/dist/sdk/sync.d.ts', import.meta.url);
const typesContent = fs.readFileSync(filePath.replace('file://', ''), 'utf8');
const url = new URL(filePath);
const typesContent = fs.readFileSync(url, 'utf8');

return `
${typesContent}
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/lib/sync.unit.cli-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, describe, it, afterEach, vi } from 'vitest';
import path from 'node:path';
import os from 'node:os';
import fs from 'fs';
import yaml from 'js-yaml';
import stripAnsi from 'strip-ansi';
Expand All @@ -12,7 +13,8 @@ import { copyDirectoryAndContents, removeVersion } from './tests/helpers.js';
import { parse } from './services/config.service.js';

function getTestDirectory(name: string) {
const dir = `/tmp/${name}/nango-integrations/`;
const tmpdir = os.tmpdir();
const dir = path.join(tmpdir, name, 'nango-integrations');
fs.mkdirSync(dir, { recursive: true });
fs.rmSync(dir, { recursive: true, force: true });
return dir;
Expand Down Expand Up @@ -480,7 +482,7 @@ describe('generate function tests', () => {

const success = await compileAllFiles({ fullPath: dir, debug: false });

const module = await import(`${dir}dist/issues-github.js`);
const module = await import(`${dir}/dist/issues-github.js`);

const result = module.default.default();
expect(result).toBe('Hello, world!');
Expand Down

0 comments on commit 578f270

Please sign in to comment.