You've already forked codtracker-js
chore: add pkg dependencies
This commit is contained in:
14
node_modules/detect-libc/index.d.ts
generated
vendored
Normal file
14
node_modules/detect-libc/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2017 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const GLIBC: 'glibc';
|
||||
export const MUSL: 'musl';
|
||||
|
||||
export function family(): Promise<string | null>;
|
||||
export function familySync(): string | null;
|
||||
|
||||
export function isNonGlibcLinux(): Promise<boolean>;
|
||||
export function isNonGlibcLinuxSync(): boolean;
|
||||
|
||||
export function version(): Promise<string | null>;
|
||||
export function versionSync(): string | null;
|
267
node_modules/detect-libc/lib/detect-libc.js
generated
vendored
Normal file
267
node_modules/detect-libc/lib/detect-libc.js
generated
vendored
Normal file
@ -0,0 +1,267 @@
|
||||
// Copyright 2017 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
const childProcess = require('child_process');
|
||||
const { isLinux, getReport } = require('./process');
|
||||
const { LDD_PATH, readFile, readFileSync } = require('./filesystem');
|
||||
|
||||
let cachedFamilyFilesystem;
|
||||
let cachedVersionFilesystem;
|
||||
|
||||
const command = 'getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true';
|
||||
let commandOut = '';
|
||||
|
||||
const safeCommand = () => {
|
||||
if (!commandOut) {
|
||||
return new Promise((resolve) => {
|
||||
childProcess.exec(command, (err, out) => {
|
||||
commandOut = err ? ' ' : out;
|
||||
resolve(commandOut);
|
||||
});
|
||||
});
|
||||
}
|
||||
return commandOut;
|
||||
};
|
||||
|
||||
const safeCommandSync = () => {
|
||||
if (!commandOut) {
|
||||
try {
|
||||
commandOut = childProcess.execSync(command, { encoding: 'utf8' });
|
||||
} catch (_err) {
|
||||
commandOut = ' ';
|
||||
}
|
||||
}
|
||||
return commandOut;
|
||||
};
|
||||
|
||||
/**
|
||||
* A String constant containing the value `glibc`.
|
||||
* @type {string}
|
||||
* @public
|
||||
*/
|
||||
const GLIBC = 'glibc';
|
||||
|
||||
/**
|
||||
* A Regexp constant to get the GLIBC Version.
|
||||
* @type {string}
|
||||
*/
|
||||
const RE_GLIBC_VERSION = /LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i;
|
||||
|
||||
/**
|
||||
* A String constant containing the value `musl`.
|
||||
* @type {string}
|
||||
* @public
|
||||
*/
|
||||
const MUSL = 'musl';
|
||||
|
||||
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-');
|
||||
|
||||
const familyFromReport = () => {
|
||||
const report = getReport();
|
||||
if (report.header && report.header.glibcVersionRuntime) {
|
||||
return GLIBC;
|
||||
}
|
||||
if (Array.isArray(report.sharedObjects)) {
|
||||
if (report.sharedObjects.some(isFileMusl)) {
|
||||
return MUSL;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const familyFromCommand = (out) => {
|
||||
const [getconf, ldd1] = out.split(/[\r\n]+/);
|
||||
if (getconf && getconf.includes(GLIBC)) {
|
||||
return GLIBC;
|
||||
}
|
||||
if (ldd1 && ldd1.includes(MUSL)) {
|
||||
return MUSL;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const getFamilyFromLddContent = (content) => {
|
||||
if (content.includes('musl')) {
|
||||
return MUSL;
|
||||
}
|
||||
if (content.includes('GNU C Library')) {
|
||||
return GLIBC;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const familyFromFilesystem = async () => {
|
||||
if (cachedFamilyFilesystem !== undefined) {
|
||||
return cachedFamilyFilesystem;
|
||||
}
|
||||
cachedFamilyFilesystem = null;
|
||||
try {
|
||||
const lddContent = await readFile(LDD_PATH);
|
||||
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
||||
} catch (e) {}
|
||||
return cachedFamilyFilesystem;
|
||||
};
|
||||
|
||||
const familyFromFilesystemSync = () => {
|
||||
if (cachedFamilyFilesystem !== undefined) {
|
||||
return cachedFamilyFilesystem;
|
||||
}
|
||||
cachedFamilyFilesystem = null;
|
||||
try {
|
||||
const lddContent = readFileSync(LDD_PATH);
|
||||
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
||||
} catch (e) {}
|
||||
return cachedFamilyFilesystem;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves with the libc family when it can be determined, `null` otherwise.
|
||||
* @returns {Promise<?string>}
|
||||
*/
|
||||
const family = async () => {
|
||||
let family = null;
|
||||
if (isLinux()) {
|
||||
family = await familyFromFilesystem();
|
||||
if (!family) {
|
||||
family = familyFromReport();
|
||||
}
|
||||
if (!family) {
|
||||
const out = await safeCommand();
|
||||
family = familyFromCommand(out);
|
||||
}
|
||||
}
|
||||
return family;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the libc family when it can be determined, `null` otherwise.
|
||||
* @returns {?string}
|
||||
*/
|
||||
const familySync = () => {
|
||||
let family = null;
|
||||
if (isLinux()) {
|
||||
family = familyFromFilesystemSync();
|
||||
if (!family) {
|
||||
family = familyFromReport();
|
||||
}
|
||||
if (!family) {
|
||||
const out = safeCommandSync();
|
||||
family = familyFromCommand(out);
|
||||
}
|
||||
}
|
||||
return family;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves `true` only when the platform is Linux and the libc family is not `glibc`.
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
const isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;
|
||||
|
||||
/**
|
||||
* Returns `true` only when the platform is Linux and the libc family is not `glibc`.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isNonGlibcLinuxSync = () => isLinux() && familySync() !== GLIBC;
|
||||
|
||||
const versionFromFilesystem = async () => {
|
||||
if (cachedVersionFilesystem !== undefined) {
|
||||
return cachedVersionFilesystem;
|
||||
}
|
||||
cachedVersionFilesystem = null;
|
||||
try {
|
||||
const lddContent = await readFile(LDD_PATH);
|
||||
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
||||
if (versionMatch) {
|
||||
cachedVersionFilesystem = versionMatch[1];
|
||||
}
|
||||
} catch (e) {}
|
||||
return cachedVersionFilesystem;
|
||||
};
|
||||
|
||||
const versionFromFilesystemSync = () => {
|
||||
if (cachedVersionFilesystem !== undefined) {
|
||||
return cachedVersionFilesystem;
|
||||
}
|
||||
cachedVersionFilesystem = null;
|
||||
try {
|
||||
const lddContent = readFileSync(LDD_PATH);
|
||||
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
||||
if (versionMatch) {
|
||||
cachedVersionFilesystem = versionMatch[1];
|
||||
}
|
||||
} catch (e) {}
|
||||
return cachedVersionFilesystem;
|
||||
};
|
||||
|
||||
const versionFromReport = () => {
|
||||
const report = getReport();
|
||||
if (report.header && report.header.glibcVersionRuntime) {
|
||||
return report.header.glibcVersionRuntime;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const versionSuffix = (s) => s.trim().split(/\s+/)[1];
|
||||
|
||||
const versionFromCommand = (out) => {
|
||||
const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
|
||||
if (getconf && getconf.includes(GLIBC)) {
|
||||
return versionSuffix(getconf);
|
||||
}
|
||||
if (ldd1 && ldd2 && ldd1.includes(MUSL)) {
|
||||
return versionSuffix(ldd2);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves with the libc version when it can be determined, `null` otherwise.
|
||||
* @returns {Promise<?string>}
|
||||
*/
|
||||
const version = async () => {
|
||||
let version = null;
|
||||
if (isLinux()) {
|
||||
version = await versionFromFilesystem();
|
||||
if (!version) {
|
||||
version = versionFromReport();
|
||||
}
|
||||
if (!version) {
|
||||
const out = await safeCommand();
|
||||
version = versionFromCommand(out);
|
||||
}
|
||||
}
|
||||
return version;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the libc version when it can be determined, `null` otherwise.
|
||||
* @returns {?string}
|
||||
*/
|
||||
const versionSync = () => {
|
||||
let version = null;
|
||||
if (isLinux()) {
|
||||
version = versionFromFilesystemSync();
|
||||
if (!version) {
|
||||
version = versionFromReport();
|
||||
}
|
||||
if (!version) {
|
||||
const out = safeCommandSync();
|
||||
version = versionFromCommand(out);
|
||||
}
|
||||
}
|
||||
return version;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
GLIBC,
|
||||
MUSL,
|
||||
family,
|
||||
familySync,
|
||||
isNonGlibcLinux,
|
||||
isNonGlibcLinuxSync,
|
||||
version,
|
||||
versionSync
|
||||
};
|
41
node_modules/detect-libc/lib/filesystem.js
generated
vendored
Normal file
41
node_modules/detect-libc/lib/filesystem.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright 2017 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
/**
|
||||
* The path where we can find the ldd
|
||||
*/
|
||||
const LDD_PATH = '/usr/bin/ldd';
|
||||
|
||||
/**
|
||||
* Read the content of a file synchronous
|
||||
*
|
||||
* @param {string} path
|
||||
* @returns {string}
|
||||
*/
|
||||
const readFileSync = (path) => fs.readFileSync(path, 'utf-8');
|
||||
|
||||
/**
|
||||
* Read the content of a file
|
||||
*
|
||||
* @param {string} path
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
const readFile = (path) => new Promise((resolve, reject) => {
|
||||
fs.readFile(path, 'utf-8', (err, data) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
LDD_PATH,
|
||||
readFileSync,
|
||||
readFile
|
||||
};
|
24
node_modules/detect-libc/lib/process.js
generated
vendored
Normal file
24
node_modules/detect-libc/lib/process.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2017 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
const isLinux = () => process.platform === 'linux';
|
||||
|
||||
let report = null;
|
||||
const getReport = () => {
|
||||
if (!report) {
|
||||
/* istanbul ignore next */
|
||||
if (isLinux() && process.report) {
|
||||
const orig = process.report.excludeNetwork;
|
||||
process.report.excludeNetwork = true;
|
||||
report = process.report.getReport();
|
||||
process.report.excludeNetwork = orig;
|
||||
} else {
|
||||
report = {};
|
||||
}
|
||||
}
|
||||
return report;
|
||||
};
|
||||
|
||||
module.exports = { isLinux, getReport };
|
40
node_modules/detect-libc/package.json
generated
vendored
Normal file
40
node_modules/detect-libc/package.json
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "detect-libc",
|
||||
"version": "2.0.3",
|
||||
"description": "Node.js module to detect the C standard library (libc) implementation family and version",
|
||||
"main": "lib/detect-libc.js",
|
||||
"files": [
|
||||
"lib/",
|
||||
"index.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "semistandard && nyc --reporter=text --check-coverage --branches=100 ava test/unit.js",
|
||||
"bench": "node benchmark/detect-libc",
|
||||
"bench:calls": "node benchmark/call-familySync.js && sleep 1 && node benchmark/call-isNonGlibcLinuxSync.js && sleep 1 && node benchmark/call-versionSync.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/lovell/detect-libc"
|
||||
},
|
||||
"keywords": [
|
||||
"libc",
|
||||
"glibc",
|
||||
"musl"
|
||||
],
|
||||
"author": "Lovell Fuller <npm@lovell.info>",
|
||||
"contributors": [
|
||||
"Niklas Salmoukas <niklas@salmoukas.com>",
|
||||
"Vinícius Lourenço <vinyygamerlol@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"ava": "^2.4.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"nyc": "^15.1.0",
|
||||
"proxyquire": "^2.1.3",
|
||||
"semistandard": "^14.2.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user