Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const assert = require('assert'),
util = require('util'),
path = require('path'),
co = require('co'),
promisify = require('promisify-node'),
exec = promisify(require('child_process').exec),
node_win = require('node-windows'),
elevate = promisify(node_win.elevate),
Service = node_win.Service,
fsx = promisify('fs-extra'),
temp = require('temp').track(),
mkdir_temp = promisify(temp.mkdir),
sid = get_sid();
co(function*() {
// We deploy everything to a temp dir to avoid creating daemon files in this repo
let temp_dir = yield mkdir_temp('pm2-windows-service-test');
// Use npm to install ourselves to the temp dir
// First thing we need is a skeleton package.json in the temp dir (otherwise it doesn't install there)
let pkg = { name: path.basename(temp_dir), version: '0.0.1' };
yield fsx.writeJson(path.resolve(temp_dir, 'package.json'), pkg);
// Now we can 'npm install' there
.map(key => new Promise((resolve, reject) => {
node_windows.elevate(`SETX ${key} "${answers[key]}" /m`, err => {
if(err) {
return reject(err);
}
resolve();
});
}));
'use strict';
const path = require('path'),
co = require('co'),
event = require('co-event'),
promisify = require('util').promisify || require('promisify-node'),
fsx = require('fs-extra'),
exec = promisify(require('child_process').exec),
node_win = require('node-windows'),
elevate = promisify(node_win.elevate),
Service = node_win.Service,
del = require('del'),
common = require('./common'),
save_dir = path.resolve(process.env.APPDATA, 'pm2-windows-service'),
sid_file = path.resolve(save_dir, '.sid'),
MAX_KILL_CHECKS = 12,
KILL_CHECK_DELAY = 5000;
module.exports = co.wrap(function*(name) {
common.check_platform();
yield common.admin_warning();
let name_from_sid_file;
try {
import { spawn } from 'child_process';
import * as fs from 'fs';
import * as net from 'net';
import * as os from 'os';
import * as path from 'path';
import { promisify } from 'util';
import * as nodeWindows from 'node-windows';
import { debug as d, logger, misc } from '@hint/utils';
import { Launcher } from '@hint/utils-debugging-protocol-common';
import { BrowserInfo, LauncherOptions } from 'hint';
const { delay } = misc;
const diagnosticsPath = require.resolve('edge-diagnostics-adapter');
const elevate = promisify(nodeWindows.elevate);
const debug = d(__filename);
export class EdgeLauncher extends Launcher {
private retryDelay: number = 500;
public constructor(options: LauncherOptions) {
super(options);
}
/** Removes all references to the client used by `isDebuggerReady`. */
private cleanup(client: net.Socket) {
client.removeAllListeners();
client.end();
client.destroy();
client.unref();