Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions io.github.lithe-idea.cargo-build/backend/provider.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { realpath } from 'node:fs/promises';
import { dirname, isAbsolute, relative, resolve, sep } from 'node:path';
import { delimiter, dirname, isAbsolute, relative, resolve, sep } from 'node:path';
import { fileURLToPath } from 'node:url';

const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
Expand Down Expand Up @@ -71,7 +71,7 @@ export function registerCargoProvider(backend, PluginError) {
const args = ['metadata', '--format-version', '1', '--no-deps', '--manifest-path', resolve(directory, 'Cargo.toml')];
if (options.offline === true) args.push('--offline');
const processEnvironment = { ...process.env, ...environment };
if (tool) processEnvironment.PATH = `${dirname(executable)}:${processEnvironment.PATH ?? ''}`;
if (tool) processEnvironment.PATH = `${dirname(executable)}${delimiter}${processEnvironment.PATH ?? ''}`;
let result;
try {
result = await context.run(executable, args, { cwd: directory, env: processEnvironment, maxOutputBytes: 8 * 1024 * 1024 });
Expand Down
4 changes: 2 additions & 2 deletions test/provider.test.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { mkdtemp, mkdir, realpath, rm, symlink, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { delimiter, join } from 'node:path';
import { pathToFileURL } from 'node:url';
import test from 'node:test';
import { createBackend, PluginError as SDKPluginError } from '../vendor/lithe-plugin-sdk/src/index.mjs';
Expand Down Expand Up @@ -57,7 +57,7 @@ test('initialization is passive; metadata uses the host tool and only supported
assert.equal(calls[0][0], '/fake-tools/cargo');
assert.deepEqual(calls[0][1], ['metadata', '--format-version', '1', '--no-deps', '--manifest-path', join(root, 'Cargo.toml'), '--offline']);
assert.equal(calls[0][2].cwd, root);
assert.ok(calls[0][2].env.PATH.startsWith('/fake-tools:'));
assert.ok(calls[0][2].env.PATH.startsWith(`/fake-tools${delimiter}`));
});

test('relative and symlink build-root escapes are refused before Cargo starts', { timeout: 5000 }, async (t) => {
Expand Down
Loading