File tree Expand file tree Collapse file tree
extensions/extension-editing/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import * as fs from 'fs' ;
76import * as path from 'path' ;
87
98import * as nls from 'vscode-nls' ;
@@ -265,12 +264,12 @@ export class ExtensionLinter {
265264
266265 private async loadPackageJson ( folder : Uri ) {
267266 const file = folder . with ( { path : path . posix . join ( folder . path , 'package.json' ) } ) ;
268- const exists = await fileExists ( file . fsPath ) ;
269- if ( ! exists ) {
267+ try {
268+ const document = await workspace . openTextDocument ( file ) ;
269+ return parseTree ( document . getText ( ) ) ;
270+ } catch ( err ) {
270271 return undefined ;
271272 }
272- const document = await workspace . openTextDocument ( file ) ;
273- return parseTree ( document . getText ( ) ) ;
274273 }
275274
276275 private packageJsonChanged ( folder : Uri ) {
@@ -338,20 +337,6 @@ function endsWith(haystack: string, needle: string): boolean {
338337 }
339338}
340339
341- function fileExists ( path : string ) : Promise < boolean > {
342- return new Promise ( ( resolve , reject ) => {
343- fs . lstat ( path , ( err , stats ) => {
344- if ( ! err ) {
345- resolve ( true ) ;
346- } else if ( err . code === 'ENOENT' ) {
347- resolve ( false ) ;
348- } else {
349- reject ( err ) ;
350- }
351- } ) ;
352- } ) ;
353- }
354-
355340function parseUri ( src : string ) {
356341 try {
357342 return Uri . parse ( src ) ;
You can’t perform that action at this time.
0 commit comments