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
2 changes: 1 addition & 1 deletion SHA256.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ make sure that their SHA values match the values in the list below.
shasum -a 256 <location_of_the_downloaded_file>

3. Confirm that the SHA in your output matches the value in this list of SHAs.
fc2d37a4f1c59206be01f30ff9384ec202632b7bb8d95b4776c4d75469377ff4 ./extensions/sfdx-code-analyzer-vscode-1.6.0.vsix
be09cbce3b4897ea3bad5a1bdffbf15835a6382d6e771ac595bec6230485f6c6 ./extensions/sfdx-code-analyzer-vscode-1.6.1.vsix
4. Change the filename extension for the file that you downloaded from .zip to
.vsix.

Expand Down
2,393 changes: 1,688 additions & 705 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"color": "#ECECEC",
"theme": "light"
},
"version": "1.6.1",
"version": "1.7.0",
"publisher": "salesforce",
"license": "BSD-3-Clause",
"engines": {
Expand Down
19 changes: 13 additions & 6 deletions src/lib/cli-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export interface CliCommandExecutor {
exec(command: string, args: string[], options?: ExecOptions): Promise<CommandOutput>
}

const IS_WINDOWS: boolean = process.platform.startsWith('win');

export class CliCommandExecutorImpl implements CliCommandExecutor {
private readonly logger: Logger;

Expand Down Expand Up @@ -104,12 +106,11 @@ export class CliCommandExecutorImpl implements CliCommandExecutor {

let childProcess: cp.ChildProcessWithoutNullStreams;
try {
childProcess = cp.spawn(command, args, {
shell: process.platform.startsWith('win'), // Use shell on Windows machines
});
childProcess = IS_WINDOWS ? cp.spawn(command, wrapArgsWithSpacesWithQuotes(args), {shell: true}) :
cp.spawn(command, args);
} catch (err) {
this.logger.logAtLevel(vscode.LogLevel.Error, `Failed to execute the following command:\n` +
indent(`${command} ${args.map(arg => arg.includes(' ') ? `"${arg}"` : arg).join(' ')}`) + `\n\n` +
indent(`${command} ${wrapArgsWithSpacesWithQuotes(args).join(' ')}`) + `\n\n` +
'Error Thrown:\n' + indent(getErrorMessageWithStack(err)));
output.stderr = getErrorMessageWithStack(err);
output.exitCode = 127;
Expand All @@ -123,7 +124,7 @@ export class CliCommandExecutorImpl implements CliCommandExecutor {
let combinedOut: string = '';

this.logger.logAtLevel(logLevel, `Executing with background process (${childProcess.pid}):\n` +
indent(`${command} ${args.map(arg => arg.includes(' ') ? `"${arg}"` : arg).join(' ')}`));
indent(`${command} ${wrapArgsWithSpacesWithQuotes(args).join(' ')}`));

childProcess.stdout.on('data', data => {
output.stdout += data;
Expand All @@ -134,8 +135,10 @@ export class CliCommandExecutorImpl implements CliCommandExecutor {
combinedOut += data;
});
childProcess.on('error', (err: Error) => {
const errMsg: string = getErrorMessageWithStack(err);
output.exitCode = 127; // 127 signifies that the command could not be executed
output.stderr += getErrorMessageWithStack(err);
output.stderr += errMsg;
combinedOut += errMsg;
resolve(output);
this.logger.logAtLevel(logLevel,
`Error from background process (${childProcess.pid}):\n${indent(combinedOut)}`);
Expand All @@ -149,3 +152,7 @@ export class CliCommandExecutorImpl implements CliCommandExecutor {
});
}
}

function wrapArgsWithSpacesWithQuotes(args: string[]): string[] {
return args.map(arg => arg.includes(' ') ? `"${arg}"` : arg);
}
8 changes: 4 additions & 4 deletions src/test/legacy/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ suite('Extension Test Suite', () => {
});

suite('sfca.runOnActiveFile', () => {
const fileUri: vscode.Uri = vscode.Uri.file(path.join(codeFixturesPath, 'folder-a', 'MyClassA1.cls'));
const fileUri: vscode.Uri = vscode.Uri.file(path.join(codeFixturesPath, 'folder a', 'MyClassA1.cls'));

setup(async function() {
// Open a file in the editor.
Expand Down Expand Up @@ -119,7 +119,7 @@ suite('Extension Test Suite', () => {
suite('sfca.runOnSelected', () => {
suite('One file selected', () => {
// Get the URI for a single file.
const targetUri: vscode.Uri = vscode.Uri.file(path.join(codeFixturesPath, 'folder-a', 'MyClassA1.cls'));
const targetUri: vscode.Uri = vscode.Uri.file(path.join(codeFixturesPath, 'folder a', 'MyClassA1.cls'));

teardown(() => {
Sinon.restore();
Expand Down Expand Up @@ -169,8 +169,8 @@ suite('Extension Test Suite', () => {

suite('Multiple files selected', () => {
// Get the URIs for two separate files.
const targetUri1: vscode.Uri = vscode.Uri.file(path.join(codeFixturesPath, 'folder-a', 'MyClassA1.cls'));
const targetUri2: vscode.Uri = vscode.Uri.file(path.join(codeFixturesPath, 'folder-a', 'MyClassA2.cls'));
const targetUri1: vscode.Uri = vscode.Uri.file(path.join(codeFixturesPath, 'folder a', 'MyClassA1.cls'));
const targetUri2: vscode.Uri = vscode.Uri.file(path.join(codeFixturesPath, 'folder a', 'MyClassA2.cls'));

teardown(() => {
Sinon.restore();
Expand Down
8 changes: 4 additions & 4 deletions src/test/legacy/fs-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ suite('file.ts', () => {
suite('#exists()', () => {

test('Returns true when file exists.', async () => {
expect(await (new FileHandlerImpl()).exists(path.join(codeFixturesPath, 'folder-a', 'MyClassA1.cls'))).to.equal(true);
expect(await (new FileHandlerImpl()).exists(path.join(codeFixturesPath, 'folder a', 'MyClassA1.cls'))).to.equal(true);
});

test('Returns false when file does not exists.', async () => {
expect(await (new FileHandlerImpl()).exists(path.join(codeFixturesPath, 'folder-a', 'UnknownFile.cls'))).to.equal(false);
expect(await (new FileHandlerImpl()).exists(path.join(codeFixturesPath, 'folder a', 'UnknownFile.cls'))).to.equal(false);
});
});

suite('#isDir()', () => {

test('Returns true when path is dir.', async () => {
expect(await (new FileHandlerImpl()).isDir(path.join(codeFixturesPath, 'folder-a'))).to.equal(true);
expect(await (new FileHandlerImpl()).isDir(path.join(codeFixturesPath, 'folder a'))).to.equal(true);
});

test('Returns false when path is file.', async () => {
expect(await (new FileHandlerImpl()).isDir(path.join(codeFixturesPath, 'folder-a', 'MyClassA1.cls'))).to.equal(false);
expect(await (new FileHandlerImpl()).isDir(path.join(codeFixturesPath, 'folder a', 'MyClassA1.cls'))).to.equal(false);
});
});
});
18 changes: 9 additions & 9 deletions src/test/legacy/targeting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ suite('targeting.ts', () => {
test('Given a real file, returns that file', async () => {
// ===== SETUP =====
// Get a URI for one file.
const singlePath: string = path.join(codeFixturesPath, "folder-a", "MyClassA1.cls");
const singlePath: string = path.join(codeFixturesPath, "folder a", "MyClassA1.cls");
const singleUri: vscode.Uri = vscode.Uri.file(singlePath);

// ===== TEST =====
Expand All @@ -48,9 +48,9 @@ suite('targeting.ts', () => {
// ===== SETUP =====
// Get a few URIs for some files in a few folders.
const multiplePaths: string[] = [
path.join(codeFixturesPath, "folder-a", "MyClassA2.cls"),
path.join(codeFixturesPath, "folder-a", "MyClassA3.cls"),
path.join(codeFixturesPath, "folder-a", "subfolder-a1", "MyClassA1i.cls"),
path.join(codeFixturesPath, "folder a", "MyClassA2.cls"),
path.join(codeFixturesPath, "folder a", "MyClassA3.cls"),
path.join(codeFixturesPath, "folder a", "subfolder-a1", "MyClassA1i.cls"),
path.join(codeFixturesPath, "folder-b", "MyClassB1.cls")
];
const multipleUris: vscode.Uri[] = multiplePaths.map(p => vscode.Uri.file(p));
Expand All @@ -71,7 +71,7 @@ suite('targeting.ts', () => {
test('Given a real folder with no subfolders, returns its contents', async () => {
// ===== SETUP =====
// Get a URI for a folder without subfolders.
const folderPath: string = path.join(codeFixturesPath, "folder-a", "subfolder-a1");
const folderPath: string = path.join(codeFixturesPath, "folder a", "subfolder-a1");
const folderUri: vscode.Uri = vscode.Uri.file(folderPath);

// ===== TEST =====
Expand All @@ -88,7 +88,7 @@ suite('targeting.ts', () => {
test('Given a real folder with subfolders, returns contents deeply', async () => {
// ===== SETUP =====
// Get a URI for a folder with subfolders.
const folderPath: string = path.join(codeFixturesPath, "folder-a");
const folderPath: string = path.join(codeFixturesPath, "folder a");
const folderUri: vscode.Uri = vscode.Uri.file(folderPath);

// ===== TEST =====
Expand All @@ -108,7 +108,7 @@ suite('targeting.ts', () => {
test('Given a non-existent file, throws error', async () => {
// ===== SETUP =====
// Get a URI for a non-existent file.
const fakeFilePath: string = path.join(codeFixturesPath, "folder-a", "DefinitelyFakeClass.cls");
const fakeFilePath: string = path.join(codeFixturesPath, "folder a", "DefinitelyFakeClass.cls");
const fakeFileUri: vscode.Uri = vscode.Uri.file(fakeFilePath);

// ===== TEST =====
Expand All @@ -128,7 +128,7 @@ suite('targeting.ts', () => {
test('Given no selection, returns no files', async () => {
// ===== SETUP =====
// Open a file in the editor.
const openFilePath: string = path.join(codeFixturesPath, 'folder-a', 'MyClassA1.cls');
const openFilePath: string = path.join(codeFixturesPath, 'folder a', 'MyClassA1.cls');
const openFileUri: vscode.Uri = vscode.Uri.file(openFilePath);
const doc: vscode.TextDocument = await vscode.workspace.openTextDocument(openFileUri);
await vscode.window.showTextDocument(doc);
Expand All @@ -143,7 +143,7 @@ suite('targeting.ts', () => {
});

suite('#getSelectedMethod()', () => {
const openFilePath: string = path.join(codeFixturesPath, 'folder-a', 'MyClassA1.cls');
const openFilePath: string = path.join(codeFixturesPath, 'folder a', 'MyClassA1.cls');
const openFileUri: vscode.Uri = vscode.Uri.file(openFilePath);
// We expect our path to be unix-ified, or else it'll parse as a glob and flunk
// the transaction.
Expand Down
Loading