Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function canRunDockerTests() {
const isLinux = os.platform() === 'linux';
const isDarwin = os.platform() === 'darwin'
// dont even try on windows / osx for now
let hasDockerStarted = false;
if (isLinux || isDarwin) {
hasDockerStarted = proc.execSync('docker info 1>/dev/null 2>&1 ; echo $?').toString('utf-8') === '0\n';
}
return hasDockerStarted;
}
[ "Default App", process.defaultApp || false ],
[ "Mac App Store App", process.mas || false ],
[ "Windows Store App", process.windowsStore || false ],
[ "Electron Version", process.versions.electron ],
[ "Node Version", process.versions.node ],
[ "V8 Version", process.versions.v8 ],
[ "Chromium Version", process.versions.chrome ],
[ "ICU Version", process.versions.icu ],
[ "Unicode Version", process.versions.unicode ],
// [ "CLDR Version", process.versions.cldr ],
// [ "Time Zone Version", process.versions.tz ],
"",
"-- Operating System --",
"",
[ "OS Type", os.type () ],
[ "OS Platform", os.platform () ],
[ "OS Release", os.release () ],
[ "CPU Architecture", os.arch () ],
[ "CPU Endianness", os.endianness () ],
[ "CPU Logical Cores", os.cpus ().length ],
[ "CPU Model", os.cpus ()[0].model ],
[ "CPU Speed (MHz)", os.cpus ()[0].speed ]
];
let systemInfo = infos.map (info => (Array.isArray (info) ? `${info[0]}: ${info[1]}` : info) + "\n").join ("");
clipboard.writeText (systemInfo);
}
//
function runEngine() {
var systemVersion = os.platform();
var userData = electron_1.app.getPath('userData');
var cmdPath;
if (systemVersion === 'win32') {
cmdPath = '/ant_' + aimVersion + '.exe';
}
else {
cmdPath = '/ant_' + aimVersion;
}
// Copy file from app.asar to user data unless find it
copyFile(electron_1.app.getAppPath() + '/torrent' + cmdPath, userData + cmdPath);
copyFile(electron_1.app.getAppPath() + '/torrent' + '/tracker.txt', userData + '/tracker.txt');
copyFile(electron_1.app.getAppPath() + '/torrent' + '/config.toml', userData + '/config.toml');
// restore broken setting file
restoreSettingFile(electron_1.app.getAppPath() + '/torrent' + '/config.toml', userData + '/config.toml');
fs.chmodSync(userData + cmdPath, '0555');
torrentEngine = child_process_1.execFile(userData + cmdPath, { cwd: userData }, function (error, stdout, stderr) {
// node-sass, chromedriver, etc.
const binaryMirrorConfig = await this.getMetadata('binary-mirror-config')
const mirrors = binaryMirrorConfig.mirrors.china
for (const key in mirrors.ENVS) {
process.env[key] = mirrors.ENVS[key]
}
// Cypress
const cypressMirror = mirrors.cypress
const defaultPlatforms = {
darwin: 'osx64',
linux: 'linux64',
win32: 'win64'
}
const platforms = cypressMirror.newPlatforms || defaultPlatforms
const targetPlatform = platforms[require('os').platform()]
// Do not override user-defined env variable
// Because we may construct a wrong download url and an escape hatch is necessary
if (targetPlatform && !process.env.CYPRESS_INSTALL_BINARY) {
// We only support cypress 3 for the current major version
const latestCypressVersion = await this.getRemoteVersion('cypress', '^3')
process.env.CYPRESS_INSTALL_BINARY =
`${cypressMirror.host}/${latestCypressVersion}/${targetPlatform}/cypress.zip`
}
} catch (e) {
// get binary mirror config failed
}
}
if (fs.existsSync('/proc/meminfo')) {
try {
const text = fs.readFileSync('/proc/meminfo', 'utf8');
const m = text && text.match(/MemAvailable:\s*(\d+)/);
if (m && m[1]) {
states.setState(id + '.memAvailable', {val: Math.round(parseInt(m[1], 10) * 0.001024), ack: true, from: id});
outputCount++;
}
} catch (err) {
logger.error('host.' + hostname + ' Cannot read /proc/meminfo: ' + err);
}
}
if (config.system.checkDiskInterval && Date.now() - lastDiskSizeCheck >= config.system.checkDiskInterval) {
lastDiskSizeCheck = Date.now();
tools.getDiskInfo(os.platform(), (err, info) => {
if (err) {
logger.error('host.' + hostname + ' Cannot read disk size: ' + err);
}
try {
if (info) {
states.setState(id + '.diskSize', {val: Math.round((info['Disk size'] || 0) / (1024 * 1024)), ack: true, from: id});
states.setState(id + '.diskFree', {val: Math.round((info['Disk free'] || 0) / (1024 * 1024)), ack: true, from: id});
outputCount+=2;
}
} catch (e) {
logger.error('host.' + hostname + ' Cannot read disk information: ' + e);
}
});
}
// some statistics
constructor (privateKey, options) {
super()
this._privateKey = Buffer.from(privateKey)
this._id = pk2id(secp256k1.publicKeyCreate(this._privateKey, false))
// options
this._timeout = options.timeout || ms('10s')
this._maxPeers = options.maxPeers || 10
this._clientId = Buffer.from(options.clientId || `ethereumjs-devp2p/v${pVersion}/${os.platform()}-${os.arch()}/nodejs`)
this._remoteClientIdFilter = options.remoteClientIdFilter
this._capabilities = options.capabilities
this._listenPort = options.listenPort
// DPT
this._dpt = options.dpt || null
if (this._dpt !== null) {
this._dpt.on('peer:new', (peer) => {
if (!peer.tcpPort) {
this._dpt.banPeer(peer, ms('5m'))
debug(`banning peer with missing tcp port: ${peer.address}`)
return
}
if (this._peersLRU.has(peer.id.toString('hex'))) return
this._peersLRU.set(peer.id.toString('hex'), true)
// var debug = require('debug')('gap');
const debug = () => {};
let events = require('events');
let os = require('os');
let util = require('util');
let Hci = require('../hci');
let isLinux = os.platform() === 'linux';
let isIntelEdison = isLinux && os.release().indexOf('edison') !== -1;
let isYocto = isLinux && os.release().indexOf('yocto') !== -1;
function Gap(hci) {
this._hci = hci;
this._advertiseState = null;
this._hci.on('error', this.onHciError.bind(this));
this._hci.on(
'leAdvertisingParametersSet',
this.onHciLeAdvertisingParametersSet.bind(this)
);
this._hci.on(
'leAdvertisingDataSet',
const defaults = require('./presets/defaults')
defaults.set()
const needle = require('needle')
const http = require('http')
const https = require('https')
const url = require('url')
const streams = require('./streams')
const childProcess = require('child_process')
const settings = require('electron-settings')
const config = require('./utils/config')
const getPort = require('get-port')
const _ = require('lodash')
const os = require('os')
const TMP = os.tmpDir()
const platform = os.platform()
const addresses = require('./utils/addressbook')
const uniqueString = require('unique-string')
const formidable = require('formidable')
const subsrt = require('subsrt')
const notifier = require('node-notifier')
const clArgs = require('./utils/clArgs')
const atob = require('./utils/atob')
const register = require('./utils/register')
const subtitles = require('./utils/subtitles')
const sslUtil = require('./utils/ssl')
(() => {
let rootPath = null;
let runtimePath = null;
const platform = os.platform();
if (platform === 'win32') {
rootPath = path.join(os.homedir(), 'AppData', 'Local', 'openvr');
runtimePath = 'C:\\Program Files (x86)\\Steam\\steamapps\\common\\SteamVR';
} else if (platform === 'darwin') {
rootPath = path.join('/Users/', os.userInfo().username, '/Library/Application Support/OpenVR/.openvr');
runtimePath = path.join(__dirname, '/node_modules/native-openvr-deps/bin/osx64');
} else if (platform === 'linux') {
rootPath = path.join(os.userInfo().homedir, '.config/openvr');
runtimePath = path.join(__dirname, 'node_modules', 'native-openvr-deps/bin/linux64');
}
if (rootPath !== null) {
const openvrPathsPath = path.join(rootPath, 'openvrpaths.vrpath');
return new Promise((accept, reject) => {
fs.lstat(openvrPathsPath, (err, stats) => {
public execute(filePath: string): void {
const command = Injector.getFileExecutionCommand(platform(), filePath);
this.handleExecution(command);
}