forked from yoctoproject/vscode-bitbake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77de4b1
commit e63ecea
Showing
4 changed files
with
100 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2023 Savoir-faire Linux. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
import fs from 'fs' | ||
|
||
import { logger } from './OutputLogger' | ||
|
||
export const getFileContent = async (path: string): Promise<string | undefined> => { | ||
const fileContent = await new Promise<string>((resolve, reject) => { | ||
fs.readFile(path, { encoding: 'utf-8' }, | ||
(error, data) => { error !== null ? reject(error) : resolve(data) } | ||
) | ||
}).catch(err => { | ||
logger.error(`Could not open file: ${err}`) | ||
return undefined | ||
}) | ||
return fileContent | ||
} |