mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-20 05:14:44 +00:00
.
This commit is contained in:
parent
00c3b50fca
commit
ae5dcb46c8
7331 changed files with 1784502 additions and 0 deletions
41
node_modules/read-pkg/index.js
generated
vendored
Normal file
41
node_modules/read-pkg/index.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
'use strict';
|
||||
const {promisify} = require('util');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const parseJson = require('parse-json');
|
||||
|
||||
const readFileAsync = promisify(fs.readFile);
|
||||
|
||||
module.exports = async options => {
|
||||
options = {
|
||||
cwd: process.cwd(),
|
||||
normalize: true,
|
||||
...options
|
||||
};
|
||||
|
||||
const filePath = path.resolve(options.cwd, 'package.json');
|
||||
const json = parseJson(await readFileAsync(filePath, 'utf8'));
|
||||
|
||||
if (options.normalize) {
|
||||
require('normalize-package-data')(json);
|
||||
}
|
||||
|
||||
return json;
|
||||
};
|
||||
|
||||
module.exports.sync = options => {
|
||||
options = {
|
||||
cwd: process.cwd(),
|
||||
normalize: true,
|
||||
...options
|
||||
};
|
||||
|
||||
const filePath = path.resolve(options.cwd, 'package.json');
|
||||
const json = parseJson(fs.readFileSync(filePath, 'utf8'));
|
||||
|
||||
if (options.normalize) {
|
||||
require('normalize-package-data')(json);
|
||||
}
|
||||
|
||||
return json;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue