Skip to content

Commit

Permalink
chore: cli.test.ts may fail on Mac/Windows (#1645)
Browse files Browse the repository at this point in the history
When using NodeJS version managers like
[nvm](https://github.com/nvm-sh/nvm) or
[fnm](https://github.com/Schniz/fnm), the NodeJS binary location can be
a bit "funny".

For example on macOS with fnm, the NodeJS binary path may contain folder
`Application Support` which has a space in it.

Wrapping the process.execPath interpolated value into quotes solves
this:
```ts
execSync(`"${process.execPath}" ${cli}`, { cwd: fixture });
```

Fixes #1644.

Co-authored-by: Eli Polonsky <[email protected]>
  • Loading branch information
aripalo and iliapolo authored Nov 25, 2024
1 parent a488c20 commit d684775
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test('construct-library', () => {
const fixture = join(`${__dirname}/__fixtures__/libraries/${libraryName}`);

// generate the documentation
execSync(`${process.execPath} ${cli}`, { cwd: fixture });
execSync(`"${process.execPath}" ${cli}`, { cwd: fixture });

const md = readFileSync(join(fixture, 'API.md'), 'utf-8');
expect(md).toMatchSnapshot();
Expand All @@ -23,7 +23,7 @@ test('specify language', () => {
const fixture = join(`${__dirname}/__fixtures__/libraries/${libraryName}`);

// generate the documentation
execSync(`${process.execPath} ${cli} --language python`, { cwd: fixture });
execSync(`"${process.execPath}" ${cli} --language python`, { cwd: fixture });

const md = readFileSync(join(fixture, 'API.md'), 'utf-8');
expect(md).toMatchSnapshot();
Expand All @@ -36,7 +36,7 @@ test('specify submodule', () => {
const fixture = join(`${__dirname}/__fixtures__/libraries/${libraryName}`);

// generate the documentation
execSync(`${process.execPath} ${cli} --submodule submod1`, { cwd: fixture });
execSync(`"${process.execPath}" ${cli} --submodule submod1`, { cwd: fixture });

const md = readFileSync(join(fixture, 'API.md'), 'utf-8');
expect(md).toMatchSnapshot();
Expand All @@ -49,7 +49,7 @@ test('specify root submodule', () => {
const fixture = join(`${__dirname}/__fixtures__/libraries/${libraryName}`);

// generate the documentation
execSync(`${process.execPath} ${cli} --submodule root`, { cwd: fixture });
execSync(`"${process.execPath}" ${cli} --submodule root`, { cwd: fixture });

const md = readFileSync(join(fixture, 'API.md'), 'utf-8');
expect(md).toMatchSnapshot();
Expand All @@ -63,7 +63,7 @@ test('split-by-submodule creates submodule files next to output', () => {
const fixture = join(`${__dirname}/__fixtures__/libraries/${libraryName}`);

// generate the documentation
execSync(`${process.execPath} ${cli} --output=docs/API.md --split-by-submodule`, { cwd: fixture });
execSync(`"${process.execPath}" ${cli} --output=docs/API.md --split-by-submodule`, { cwd: fixture });

const rootMd = readFileSync(join(fixture, 'docs/API.md'), 'utf-8');
const submoduleMd = readFileSync(join(fixture, 'docs/submod1.md'), 'utf-8');
Expand All @@ -83,7 +83,7 @@ test('specify languages and split-by-submodule creates submodule files next to o
const fixture = join(`${__dirname}/__fixtures__/libraries/${libraryName}`);

// generate the documentation
execSync(`${process.execPath} ${cli} --output=docs/API.md --split-by-submodule -l typescript -l python`, { cwd: fixture });
execSync(`"${process.execPath}" ${cli} --output=docs/API.md --split-by-submodule -l typescript -l python`, { cwd: fixture });

// TypeScript
const rootTs = readFileSync(join(fixture, 'docs/API.typescript.md'), 'utf-8');
Expand Down

0 comments on commit d684775

Please sign in to comment.