mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-24 06:44:44 +00:00
.
This commit is contained in:
parent
fc725ba36b
commit
422b9fdb15
7395 changed files with 1786235 additions and 3476 deletions
42
node_modules/cosmiconfig/dist/readFile.js
generated
vendored
Normal file
42
node_modules/cosmiconfig/dist/readFile.js
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
//
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function readFile(filepath , options ) {
|
||||
options = options || {};
|
||||
const throwNotFound = options.throwNotFound || false;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(filepath, 'utf8', (err, content) => {
|
||||
if (err && err.code === 'ENOENT' && !throwNotFound) {
|
||||
return resolve(null);
|
||||
}
|
||||
if (err) return reject(err);
|
||||
resolve(content);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
readFile.sync = function readFileSync(
|
||||
filepath ,
|
||||
options
|
||||
) {
|
||||
options = options || {};
|
||||
const throwNotFound = options.throwNotFound || false;
|
||||
|
||||
try {
|
||||
return fs.readFileSync(filepath, 'utf8');
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT' && !throwNotFound) {
|
||||
return null;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = readFile;
|
Loading…
Add table
Add a link
Reference in a new issue