Skip to content

Commit d9e5ad7

Browse files
committed
refactor: SImplify rollup plugin
1 parent c1af017 commit d9e5ad7

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

rollup/rollup-plugin-remove-vscode-declare-module.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,15 @@ const plugin: PluginImpl<{}> = () => {
99
if (id.endsWith('@types/vscode/index.d.ts')) {
1010
const lines = code.split('\n')
1111
let index = lines.indexOf('declare module \'vscode\' {')
12+
if (index < 0) throw new Error('Module declaration not found')
13+
1214
lines.splice(index, 1)
13-
if (index >= 0) {
14-
let end = false
15-
while (!end) {
16-
if (lines[index] === '}') {
17-
lines.splice(index, 1)
18-
end = true
19-
} else {
20-
// unindent
21-
lines[index] = lines[index].slice(4)
22-
}
23-
index++
24-
}
15+
for (; lines[index] !== '}'; index++) {
16+
// unindent
17+
lines[index] = lines[index].slice(4)
2518
}
19+
lines.splice(index, 1)
20+
2621
return lines.join('\n')
2722
}
2823
return code

0 commit comments

Comments
 (0)