Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var hasUnicode = module.exports = function () {
// Recent Win32 platforms (>XP) CAN support unicode in the console but
// don't have to, and in non-english locales often use traditional local
// code pages. There's no way, short of windows system calls or execing
// the chcp command line program to figure this out. As such, we default
// this to false and encourage your users to override it via config if
// appropriate.
if (os.type() == "Windows_NT") { return false }
var isUTF8 = /UTF-?8$/i
var ctype = process.env.LC_ALL || process.env.LC_CTYPE || process.env.LANG
return isUTF8.test(ctype)
}
default:
log.error("", er.stack || er.message || er)
log.error("", ["If you need help, you may report this log at:"
," "
,"or email it to:"
," "
].join("\n"))
printStack = false
break
}
var os = require("os")
// just a line break
console.error("")
log.error("System", os.type() + " " + os.release())
log.error("command", process.argv
.map(JSON.stringify).join(" "))
log.error("cwd", process.cwd())
log.error("node -v", process.version)
log.error("npm -v", npm.version)
; [ "file"
, "path"
, "type"
, "syscall"
, "fstream_path"
, "fstream_unc_path"
, "fstream_type"
, "fstream_class"
, "fstream_finish_call"
, "fstream_linkpath"
throw new TypeError(
'The second argument must be a function callback. You have passed ' +
typeof callback
);
}
if (typeof options === 'string') {
options = { title: 'node-notifier', message: options };
}
if (!options.message) {
callback(new Error('Message is required.'));
return this;
}
if (os.type() !== 'Linux' && !os.type().match(/BSD$/)) {
callback(new Error('Only supported on Linux and *BSD systems'));
return this;
}
if (hasNotifier === false) {
callback(new Error('notify-send must be installed on the system.'));
return this;
}
if (hasNotifier || !!this.options.suppressOsdCheck) {
doNotification(options, callback);
return this;
}
try {
hasNotifier = !!which.sync(notifier);
function handleError(error, options) {
var cause = error.cause;
logError(error.message, 'message');
while (cause) {
logError(cause.message, 'caused by');
cause = cause.cause;
}
if (options.verbose && error.stack) {
log('');
logError(error.stack, 'stack');
}
log('');
logError(process.cwd(), 'cwd');
logError(os.type() + " " + os.release(), 'system');
logError(process.argv.map(JSON.stringify).join(' '), 'command');
logError(process.version, 'node -v');
logError(pkg.version, "typings -v");
if (error.code) {
logError(error.code, 'code');
}
log('');
logError('If you need help, you may report this error at:');
logError(" ");
process.exit(1);
}
exports.handleError = handleError;
export function pathToUri(pathStr : string): string{
let retUri;
if (os.type() == "Windows_NT") {
let pathArr = pathStr.split( path.sep );
let stdPath = pathArr.join('/');
retUri = 'file:///' + stdPath;
}
else{
//Darwin
retUri = 'file://' + pathStr;
}
return retUri;
}
debug: false,
minTimeout: 200,
maxRetries: 5,
sendImmediately: false,
sendInterval: 10000,
maxSize: 25,
transformError: error => error,
...options,
};
this.schemaHash = hashSchema(options.schema);
this.metadata = {
agent: `1.2.3`,
runtime: `node ${process.version}`,
uname: `${os.platform()}, ${os.type()}, ${os.release()}, ${os.arch()}`,
hostname: os.hostname(),
schemaHash: this.schemaHash,
schemaTag: this.options.tag,
};
this.report = {
metadata: this.metadata,
traces: [],
};
if (!this.options.sendImmediately) {
this.intervalID = setInterval(() => {
this.send().catch(e => {
console.error(e);
});
}, this.options.sendInterval);
function read_drives() {
if (os.type() === 'Windows_NT') {
return read_windows_drives();
} else {
return read_mac_linux_drives();
}
}
function getExecutableExtension(): string {
if (os.type().match(/^Win/)) {
return '.exe';
}
return '';
}
private downloadCli(callback: (string, error) => void) {
const dlDir = util.tmpdir('cb-cli-dl');
let arch = os.arch();
if(arch == "ia32") arch = "x32";
const plat = os.type() + (os.type() !== 'Darwin' ? "_" + arch : '');
const url: string = this.downloads.arduino_cli[plat];
util
.download(url, dlDir)
.then((file) => {
callback(file, null);
})
.catch((err) => {
callback(null, err);
});
}
let config_promise = new Promise((resolve, reject) => {
let config = {
release: app.getVersion(),
environment: is.dev() ? 'development' : 'production',
name: osName(),
tags: {
os_arch: os.arch(),
os_platform: os.platform(),
os_release: os.release(),
os_version: process.getSystemVersion(),
os_type: os.type(),
os_totalmem: os_totalmem_gb + 'GB',
hostname: app.config.get('host'),
user_style: app.config.get('acceptUserStyles'),
user_script: app.config.get('acceptUserScripts'),
tray: app.config.get('tray'),
menu_bar: app.config.get('menu-bar')
},
dataCallback: (data) => {
if (user) {
data.user = {
id: user.id,
name: user.name,
email: user.email
};
}
let os_freemem = os.freemem() / 1024 / 1024;