Skip to content

Commit d30c057

Browse files
committed
switch to checking if OS is mac
1 parent fa1b53b commit d30c057

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

packages/core/src/awsService/ec2/model.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,14 @@ export class Ec2Connecter implements vscode.Disposable {
342342
}
343343

344344
/**
345-
* Generate bash command (as string) to remove lines in file suffixed by `hintComment`.
346-
* @param hintComment suffix comment for deleted lines.
345+
* Generate bash command (as string) to remove lines containing `hintComment`.
346+
* @param pattern pattern for deleted lines.
347347
* @param filepath filepath (as string) to target with the command.
348348
* @returns bash command to remove lines from file.
349349
*/
350-
export function getRemoveLinesCommand(hintComment: string, hostOS: Ec2OS, filepath: string): string {
350+
export function getRemoveLinesCommand(pattern: string, hostOS: Ec2OS, filepath: string): string {
351351
// Linux allows not passing extension to -i, whereas macOS requires zero length extension.
352-
return `sed -i ${isLinux(hostOS) ? '' : "''"} /${hintComment}/d ${filepath}`
352+
return `sed -i ${isLinux(hostOS) ? '' : "''"} /${pattern}/d ${filepath}`
353353
}
354354

355355
function isLinux(os: Ec2OS): boolean {

packages/core/src/shared/vscode/env.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export function isRemoteWorkspace(): boolean {
134134
* Example: `5.10.220-188.869.amzn2int.x86_64`
135135
*/
136136
export function isAmazonInternalOs() {
137-
return os.release().includes('amzn2int') && isLinux()
137+
return os.release().includes('amzn2int') && process.platform === 'linux'
138138
}
139139

140140
/**
@@ -149,6 +149,9 @@ export async function isCloudDesktop() {
149149
return (await new ChildProcess('/apollo/bin/getmyfabric').run().then((r) => r.exitCode)) === 0
150150
}
151151

152+
export function isMac(): boolean {
153+
return process.platform === 'darwin'
154+
}
152155
/** Returns true if OS is Windows. */
153156
export function isWin(): boolean {
154157
// if (isWeb()) {
@@ -158,10 +161,6 @@ export function isWin(): boolean {
158161
return process.platform === 'win32'
159162
}
160163

161-
export function isLinux(): boolean {
162-
return process.platform === 'linux'
163-
}
164-
165164
const UIKind = {
166165
[vscode.UIKind.Desktop]: 'desktop',
167166
[vscode.UIKind.Web]: 'web',

packages/core/src/test/awsService/ec2/model.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { assertNoTelemetryMatch, createTestWorkspaceFolder } from '../../testUti
1717
import { fs } from '../../../shared'
1818
import path from 'path'
1919
import { ChildProcess } from '../../../shared/utilities/processUtils'
20-
import { isLinux, isWin } from '../../../shared/vscode/env'
20+
import { isMac, isWin } from '../../../shared/vscode/env'
2121

2222
describe('Ec2ConnectClient', function () {
2323
let client: Ec2Connecter
@@ -213,12 +213,12 @@ describe('getRemoveLinesCommand', async function () {
213213
await fs.delete(tempPath.uri.fsPath, { recursive: true, force: true })
214214
})
215215

216-
it('removes lines prefixed by pattern', async function () {
216+
it('removes lines containing pattern', async function () {
217217
if (isWin()) {
218218
this.skip()
219219
}
220220
// For the test, we only need to distinguish mac and linux
221-
const hostOS = isLinux() ? 'Amazon Linux' : 'macOS'
221+
const hostOS = isMac() ? 'macOS' : 'Amazon Linux'
222222
const lines = ['line1', 'line2 pattern', 'line3', 'line4 pattern', 'line5', 'line6 pattern', 'line7']
223223
const expected = ['line1', 'line3', 'line5', 'line7']
224224

0 commit comments

Comments
 (0)