Skip to content

Commit fd4cb0d

Browse files
committed
chore: check prettier properly in CI
1 parent d0990a8 commit fd4cb0d

File tree

7 files changed

+96
-55
lines changed

7 files changed

+96
-55
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Install npm dependencies
3636
run: npm ci
3737
- name: Prettier
38-
run: npm run prettier
38+
run: npm run prettier-check
3939
- name: Lint
4040
run: npm run tslint
4141
- name: Build VS Code extension

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"singleQuote": true,
88
"printWidth": 120,
99
"proseWrap": "preserve",
10+
"arrowParens": "avoid",
1011
"overrides": [
1112
{
1213
"files": "{*.js?(on),*.yml,.*.yml,.prettierrc,*.md}",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"lint": "npm run tslint && npm run prettier",
9999
"tslint": "tslint -c tslint.json 'src/**/*.ts'",
100100
"prettier": "prettier \"**/{*.json,*.yml,.*.yml,*.ts,.prettierrc,*.md}\" --write --list-different",
101+
"prettier-check": "npm run prettier -- --write=false",
101102
"semantic-release": "semantic-release",
102103
"commitmsg": "validate-commit-msg"
103104
},

src/paths.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ export function convertClientPathToDebugger(localPath: string, pathMapping?: { [
5353
let localSourceRoot: string | undefined
5454
let serverSourceRoot: string | undefined
5555
// XDebug always lowercases Windows drive letters in file URIs
56-
let localFileUri = fileUrl(localPath.replace(/^[A-Z]:\\/, match => match.toLowerCase()), { resolve: false })
56+
let localFileUri = fileUrl(
57+
localPath.replace(/^[A-Z]:\\/, match => match.toLowerCase()),
58+
{ resolve: false }
59+
)
5760
let serverFileUri: string
5861
if (pathMapping) {
5962
for (const mappedServerPath of Object.keys(pathMapping)) {

src/phpDebug.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,7 @@ class PhpDebugSession extends vscode.DebugSession {
315315
this.sendEvent(new vscode.OutputEvent(util.inspect(error) + '\n'))
316316
this.sendErrorResponse(response, <Error>error)
317317
})
318-
server.listen(
319-
args.port || 9000,
320-
args.hostname,
321-
() => resolve()
322-
)
318+
server.listen(args.port || 9000, args.hostname, () => resolve())
323319
})
324320
try {
325321
if (!args.noDebug) {

src/terminal.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,23 @@ export class Terminal {
4646
}
4747

4848
interface ITerminalService {
49-
launchInTerminal(dir: string, args: string[], envVars: { [key: string]: string | undefined }): Promise<CP.ChildProcess | undefined>
49+
launchInTerminal(
50+
dir: string,
51+
args: string[],
52+
envVars: { [key: string]: string | undefined }
53+
): Promise<CP.ChildProcess | undefined>
5054
killTree(pid: number): Promise<any>
5155
isOnPath(program: string): boolean
5256
}
5357

5458
class DefaultTerminalService implements ITerminalService {
5559
protected static TERMINAL_TITLE = 'VS Code Console'
5660

57-
public launchInTerminal(dir: string, args: string[], envVars: { [key: string]: string }): Promise<CP.ChildProcess | undefined> {
61+
public launchInTerminal(
62+
dir: string,
63+
args: string[],
64+
envVars: { [key: string]: string }
65+
): Promise<CP.ChildProcess | undefined> {
5866
throw new Error('launchInTerminal not implemented')
5967
}
6068

@@ -100,7 +108,11 @@ class DefaultTerminalService implements ITerminalService {
100108
class WindowsTerminalService extends DefaultTerminalService {
101109
private static CMD = 'cmd.exe'
102110

103-
public launchInTerminal(dir: string, args: string[], envVars: { [key: string]: string }): Promise<CP.ChildProcess | undefined> {
111+
public launchInTerminal(
112+
dir: string,
113+
args: string[],
114+
envVars: { [key: string]: string }
115+
): Promise<CP.ChildProcess | undefined> {
104116
return new Promise<CP.ChildProcess | undefined>((resolve, reject) => {
105117
const title = `"${dir} - ${WindowsTerminalService.TERMINAL_TITLE}"`
106118
const command = `""${args.join('" "')}" & pause"` // use '|' to only pause on non-zero exit code
@@ -143,14 +155,16 @@ class LinuxTerminalService extends DefaultTerminalService {
143155
private static LINUX_TERM = '/usr/bin/gnome-terminal' // private const string LINUX_TERM = "/usr/bin/x-terminal-emulator";
144156
private static WAIT_MESSAGE = 'Press any key to continue...'
145157

146-
public launchInTerminal(dir: string, args: string[], envVars: { [key: string]: string }): Promise<CP.ChildProcess | undefined> {
158+
public launchInTerminal(
159+
dir: string,
160+
args: string[],
161+
envVars: { [key: string]: string }
162+
): Promise<CP.ChildProcess | undefined> {
147163
return new Promise<CP.ChildProcess | undefined>((resolve, reject) => {
148164
if (!FS.existsSync(LinuxTerminalService.LINUX_TERM)) {
149165
reject(
150166
new Error(
151-
`Cannot find '${
152-
LinuxTerminalService.LINUX_TERM
153-
}' for launching the node program. See http://go.microsoft.com/fwlink/?linkID=534832#_20002`
167+
`Cannot find '${LinuxTerminalService.LINUX_TERM}' for launching the node program. See http://go.microsoft.com/fwlink/?linkID=534832#_20002`
154168
)
155169
)
156170
return
@@ -193,7 +207,11 @@ class LinuxTerminalService extends DefaultTerminalService {
193207
class MacTerminalService extends DefaultTerminalService {
194208
private static OSASCRIPT = '/usr/bin/osascript' // osascript is the AppleScript interpreter on OS X
195209

196-
public launchInTerminal(dir: string, args: string[], envVars: { [key: string]: string }): Promise<CP.ChildProcess | undefined> {
210+
public launchInTerminal(
211+
dir: string,
212+
args: string[],
213+
envVars: { [key: string]: string }
214+
): Promise<CP.ChildProcess | undefined> {
197215
return new Promise<CP.ChildProcess | undefined>((resolve, reject) => {
198216
// first fix the PATH so that 'runtimePath' can be found if installed with 'brew'
199217
// Utilities.FixPathOnOSX();

src/test/adapter.ts

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ describe('PHP Debug Adapter', () => {
102102
describe('line breakpoints', () => {
103103
async function testBreakpointHit(program: string, line: number): Promise<void> {
104104
await Promise.all([client.launch({ program }), client.waitForEvent('initialized')])
105-
const breakpoint = (await client.setBreakpointsRequest({
106-
breakpoints: [{ line }],
107-
source: { path: program },
108-
})).body.breakpoints[0]
105+
const breakpoint = (
106+
await client.setBreakpointsRequest({
107+
breakpoints: [{ line }],
108+
source: { path: program },
109+
})
110+
).body.breakpoints[0]
109111
assert.isTrue(breakpoint.verified, 'breakpoint verification mismatch: verified')
110112
assert.equal(breakpoint.line, line, 'breakpoint verification mismatch: line')
111113
await Promise.all([
@@ -124,10 +126,12 @@ describe('PHP Debug Adapter', () => {
124126
it('should support removing a breakpoint', async () => {
125127
await Promise.all([client.launch({ program }), client.waitForEvent('initialized')])
126128
// set two breakpoints
127-
let breakpoints = (await client.setBreakpointsRequest({
128-
breakpoints: [{ line: 3 }, { line: 5 }],
129-
source: { path: program },
130-
})).body.breakpoints
129+
let breakpoints = (
130+
await client.setBreakpointsRequest({
131+
breakpoints: [{ line: 3 }, { line: 5 }],
132+
source: { path: program },
133+
})
134+
).body.breakpoints
131135
assert.lengthOf(breakpoints, 2)
132136
assert.isTrue(breakpoints[0].verified, 'breakpoint verification mismatch: verified')
133137
assert.equal(breakpoints[0].line, 3, 'breakpoint verification mismatch: line')
@@ -139,10 +143,12 @@ describe('PHP Debug Adapter', () => {
139143
client.configurationDoneRequest(),
140144
])
141145
// remove second
142-
breakpoints = (await client.setBreakpointsRequest({
143-
breakpoints: [{ line: 3 }],
144-
source: { path: program },
145-
})).body.breakpoints
146+
breakpoints = (
147+
await client.setBreakpointsRequest({
148+
breakpoints: [{ line: 3 }],
149+
source: { path: program },
150+
})
151+
).body.breakpoints
146152
assert.lengthOf(breakpoints, 1)
147153
assert.isTrue(breakpoints[0].verified, 'breakpoint verification mismatch: verified')
148154
assert.equal(breakpoints[0].line, 3, 'breakpoint verification mismatch: line')
@@ -243,9 +249,11 @@ describe('PHP Debug Adapter', () => {
243249
async function getErrorScope(): Promise<ErrorScope> {
244250
const frameId = (await client.stackTraceRequest({ threadId: threadId! })).body.stackFrames[0].id
245251
const errorScope = (await client.scopesRequest({ frameId })).body.scopes[0]
246-
const variables = (await client.variablesRequest({
247-
variablesReference: errorScope.variablesReference,
248-
})).body.variables
252+
const variables = (
253+
await client.variablesRequest({
254+
variablesReference: errorScope.variablesReference,
255+
})
256+
).body.variables
249257
const errorInfo: ErrorScope = { name: errorScope.name }
250258
const type = variables.find(variable => variable.name === 'type')
251259
if (type) {
@@ -301,30 +309,36 @@ describe('PHP Debug Adapter', () => {
301309

302310
it('should stop on a conditional breakpoint when condition is true', async () => {
303311
await Promise.all([client.launch({ program }), client.waitForEvent('initialized')])
304-
const bp = (await client.setBreakpointsRequest({
305-
breakpoints: [{ line: 10, condition: '$anInt === 123' }],
306-
source: { path: program },
307-
})).body.breakpoints[0]
312+
const bp = (
313+
await client.setBreakpointsRequest({
314+
breakpoints: [{ line: 10, condition: '$anInt === 123' }],
315+
source: { path: program },
316+
})
317+
).body.breakpoints[0]
308318
assert.equal(bp.verified, true, 'breakpoint verification mismatch: verified')
309319
assert.equal(bp.line, 10, 'breakpoint verification mismatch: line')
310320
const [, { frame }] = await Promise.all([
311321
client.configurationDoneRequest(),
312322
assertStoppedLocation('breakpoint', program, 10),
313323
])
314-
const result = (await client.evaluateRequest({
315-
context: 'watch',
316-
frameId: frame.id,
317-
expression: '$anInt',
318-
})).body.result
324+
const result = (
325+
await client.evaluateRequest({
326+
context: 'watch',
327+
frameId: frame.id,
328+
expression: '$anInt',
329+
})
330+
).body.result
319331
assert.equal(result, '123')
320332
})
321333

322334
it('should not stop on a conditional breakpoint when condition is false', async () => {
323335
await Promise.all([client.launch({ program }), client.waitForEvent('initialized')])
324-
const bp = (await client.setBreakpointsRequest({
325-
breakpoints: [{ line: 10, condition: '$anInt !== 123' }],
326-
source: { path: program },
327-
})).body.breakpoints[0]
336+
const bp = (
337+
await client.setBreakpointsRequest({
338+
breakpoints: [{ line: 10, condition: '$anInt !== 123' }],
339+
source: { path: program },
340+
})
341+
).body.breakpoints[0]
328342
assert.equal(bp.verified, true, 'breakpoint verification mismatch: verified')
329343
assert.equal(bp.line, 10, 'breakpoint verification mismatch: line')
330344
await Promise.all([client.configurationDoneRequest(), client.waitForEvent('terminated')])
@@ -337,9 +351,11 @@ describe('PHP Debug Adapter', () => {
337351
it('should stop on a function breakpoint', async () => {
338352
await client.launch({ program })
339353
await client.waitForEvent('initialized')
340-
const breakpoint = (await client.setFunctionBreakpointsRequest({
341-
breakpoints: [{ name: 'a_function' }],
342-
})).body.breakpoints[0]
354+
const breakpoint = (
355+
await client.setFunctionBreakpointsRequest({
356+
breakpoints: [{ name: 'a_function' }],
357+
})
358+
).body.breakpoints[0]
343359
assert.strictEqual(breakpoint.verified, true)
344360
await Promise.all([client.configurationDoneRequest(), assertStoppedLocation('breakpoint', program, 5)])
345361
})
@@ -434,9 +450,11 @@ describe('PHP Debug Adapter', () => {
434450
assert.isDefined(aLargeArray)
435451
assert.propertyVal(aLargeArray!, 'value', 'array(100)')
436452
assert.property(aLargeArray!, 'variablesReference')
437-
const largeArrayItems = (await client.variablesRequest({
438-
variablesReference: aLargeArray!.variablesReference,
439-
})).body.variables
453+
const largeArrayItems = (
454+
await client.variablesRequest({
455+
variablesReference: aLargeArray!.variablesReference,
456+
})
457+
).body.variables
440458
assert.lengthOf(largeArrayItems, 100)
441459
assert.propertyVal(largeArrayItems[0], 'name', '0')
442460
assert.propertyVal(largeArrayItems[0], 'value', '"test"')
@@ -449,9 +467,11 @@ describe('PHP Debug Adapter', () => {
449467
assert.isDefined(arrayWithSpaceKey)
450468
assert.propertyVal(arrayWithSpaceKey!, 'value', 'array(1)')
451469
assert.property(arrayWithSpaceKey!, 'variablesReference')
452-
const arrayWithSpaceKeyItems = (await client.variablesRequest({
453-
variablesReference: arrayWithSpaceKey!.variablesReference,
454-
})).body.variables
470+
const arrayWithSpaceKeyItems = (
471+
await client.variablesRequest({
472+
variablesReference: arrayWithSpaceKey!.variablesReference,
473+
})
474+
).body.variables
455475
assert.lengthOf(arrayWithSpaceKeyItems, 1)
456476
assert.propertyVal(arrayWithSpaceKeyItems[0], 'name', 'space key')
457477
assert.propertyVal(arrayWithSpaceKeyItems[0], 'value', '1')
@@ -461,9 +481,11 @@ describe('PHP Debug Adapter', () => {
461481
// support for user defined constants was added in 2.3.0
462482
if (!process.env['XDEBUG_VERSION'] || semver.gte(process.env['XDEBUG_VERSION'], '2.3.0')) {
463483
it('should report user defined constants correctly', async () => {
464-
const constants = (await client.variablesRequest({
465-
variablesReference: constantsScope!.variablesReference,
466-
})).body.variables
484+
const constants = (
485+
await client.variablesRequest({
486+
variablesReference: constantsScope!.variablesReference,
487+
})
488+
).body.variables
467489
assert.lengthOf(constants, 1)
468490
assert.propertyVal(constants[0], 'name', 'TEST_CONSTANT')
469491
assert.propertyVal(constants[0], 'value', '123')

0 commit comments

Comments
 (0)