Socket
Socket
Sign inDemoInstall

nuke-msbuild

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.6 to 1.0.7

13

dist/index.js
#!/usr/bin/env node
const exec = require("child_process").exec;
const processConfig = {
cwd: "C:/WINDOWS/system32"
};
const getEmptySpacesUntilNextCharacter = (source, start) => {

@@ -46,3 +49,3 @@ const chars = source.split("");

id: currentGroupIndex,
data: char,
data: char
};

@@ -70,5 +73,5 @@ groups.push(group);

number: Number(columns[3]),
name: columns[2],
name: columns[2]
},
memory: columns[4],
memory: columns[4]
};

@@ -82,3 +85,3 @@ };

};
exec("tasklist", (err, stdout, stderr) => {
exec("tasklist", processConfig, (err, stdout, stderr) => {
if (err)

@@ -94,3 +97,3 @@ console.log("There was an error getting task list.");

MSBuildProcesses.forEach(({ pid, name }) => {
exec(`taskkill /F /PID ${pid}`, (err, stdout, stderr) => {
exec(`taskkill /F /PID ${pid}`, processConfig, (err, stdout, stderr) => {
if (err) {

@@ -97,0 +100,0 @@ console.log(`Failed to destroy MSBuild process: ${pid}`);

{
"name": "nuke-msbuild",
"version": "1.0.6",
"version": "1.0.7",
"description": "Nuke all active MSBuild processes with a simple command.",
"main": "./dist/index.js",
"os": [
"win32"
],
"scripts": {

@@ -7,0 +10,0 @@ "build": "tsc",

#!/usr/bin/env node
const exec = require("child_process").exec;
const processConfig = {
cwd: "C:/WINDOWS/system32"
};
interface Session {
number: number;
name: string;
number: number;
name: string;
}
interface Process {
pid: number;
name: string;
session: Session;
memory: number;
pid: number;
name: string;
session: Session;
memory: number;
}
interface Group {
id: number;
data: string;
id: number;
data: string;
}
const getEmptySpacesUntilNextCharacter = (source: string, start: number) => {
const chars = source.split("");
const target = chars.slice(start);
let spaces = 0;
let currentIndex = 0;
const chars = source.split("");
const target = chars.slice(start);
let spaces = 0;
let currentIndex = 0;
for (const char of target) {
const isEmpty = char.trim().length === 0;
if (!isEmpty) break;
spaces++;
currentIndex++;
}
for (const char of target) {
const isEmpty = char.trim().length === 0;
if (!isEmpty) break;
spaces++;
currentIndex++;
}
return spaces;
return spaces;
};
const matchTextGroups = (source: string, pattern: string): Array<string> => {
const chars = source.split("");
const settings = pattern.split("x").filter((char) => char.length);
const groups: Array<Group> = [];
const chars = source.split("");
const settings = pattern.split("x").filter((char) => char.length);
const groups: Array<Group> = [];
let prevGroupIndex = 0;
let currentGroupIndex = 0;
let currentSettingIndex = 0;
let prevGroupIndex = 0;
let currentGroupIndex = 0;
let currentSettingIndex = 0;
chars.forEach((char, index) => {
let isSpace = char.trim().length === 0;
chars.forEach((char, index) => {
let isSpace = char.trim().length === 0;
let currentSetting = settings[currentSettingIndex] ?? "+";
let minSpaces = currentSetting.match(/_/g)?.length ?? 1;
let shouldMatchMultipleSpaces = currentSetting.includes("+");
let currentSetting = settings[currentSettingIndex] ?? "+";
let minSpaces = currentSetting.match(/_/g)?.length ?? 1;
let shouldMatchMultipleSpaces = currentSetting.includes("+");
if (isSpace) {
const nextSpaces = getEmptySpacesUntilNextCharacter(source, index);
const shouldSwitchGroup = shouldMatchMultipleSpaces
? nextSpaces > minSpaces
: nextSpaces == minSpaces;
if (isSpace) {
const nextSpaces = getEmptySpacesUntilNextCharacter(source, index);
const shouldSwitchGroup = shouldMatchMultipleSpaces
? nextSpaces > minSpaces
: nextSpaces == minSpaces;
if (shouldSwitchGroup) {
currentGroupIndex++;
return;
}
}
if (shouldSwitchGroup) {
currentGroupIndex++;
return;
}
}
const groupSwitched = prevGroupIndex !== currentGroupIndex;
const canUpdateSetting = currentSettingIndex < settings.length - 1;
const groupSwitched = prevGroupIndex !== currentGroupIndex;
const canUpdateSetting = currentSettingIndex < settings.length - 1;
if (groupSwitched) if (canUpdateSetting) currentSettingIndex++;
if (groupSwitched) if (canUpdateSetting) currentSettingIndex++;
const group = {
id: currentGroupIndex,
data: char,
};
const group = {
id: currentGroupIndex,
data: char
};
groups.push(group);
groups.push(group);
prevGroupIndex = Number(currentGroupIndex);
});
prevGroupIndex = Number(currentGroupIndex);
});
const filtered = groups
.map(({ id }) => id)
.filter((group, index, self) => self.indexOf(group) === index);
return filtered.map((target) =>
groups
.filter(({ id }) => id === target)
.map(({ data }) => data)
.join("")
.trim()
);
const filtered = groups
.map(({ id }) => id)
.filter((group, index, self) => self.indexOf(group) === index);
return filtered.map((target) =>
groups
.filter(({ id }) => id === target)
.map(({ data }) => data)
.join("")
.trim()
);
};
const getColumnsFromRow = (row: string) => {
return matchTextGroups(row, "x_+x_x_+x_+x");
return matchTextGroups(row, "x_+x_x_+x_+x");
};
const columnsAsProcess = (columns) => {
return {
pid: Number(columns[1]),
name: columns[0],
session: {
number: Number(columns[3]),
name: columns[2],
},
memory: columns[4] as unknown as number,
} as Process;
return {
pid: Number(columns[1]),
name: columns[0],
session: {
number: Number(columns[3]),
name: columns[2]
},
memory: columns[4] as unknown as number
} as Process;
};

@@ -111,28 +114,28 @@

const getProcessListFromText = (text: string): Array<Process> => {
const sanitized = text.substring(text.lastIndexOf("="), text.length - 1);
const rows = sanitized.split("\n");
return rows.map(rowAsColumns).map(columnsAsProcess);
const sanitized = text.substring(text.lastIndexOf("="), text.length - 1);
const rows = sanitized.split("\n");
return rows.map(rowAsColumns).map(columnsAsProcess);
};
exec("tasklist", (err, stdout, stderr) => {
if (err) console.log("There was an error getting task list.");
exec("tasklist", processConfig, (err, stdout, stderr) => {
if (err) console.log("There was an error getting task list.");
const processes = getProcessListFromText(stdout);
const MSBuildProcesses = processes.filter((process) => {
if (process?.name)
return process.name?.toLowerCase().includes("msbuild");
});
const processes = getProcessListFromText(stdout);
const MSBuildProcesses = processes.filter((process) => {
if (process?.name)
return process.name?.toLowerCase().includes("msbuild");
});
if (!MSBuildProcesses.length)
console.log("No MSBuild processes currently running.");
if (!MSBuildProcesses.length)
console.log("No MSBuild processes currently running.");
MSBuildProcesses.forEach(({ pid, name }) => {
exec(`taskkill /F /PID ${pid}`, (err, stdout, stderr) => {
if (err) {
console.log(`Failed to destroy MSBuild process: ${pid}`);
return;
}
console.log(`Nuked ${name} with PID: ${pid}`);
});
MSBuildProcesses.forEach(({ pid, name }) => {
exec(`taskkill /F /PID ${pid}`, processConfig, (err, stdout, stderr) => {
if (err) {
console.log(`Failed to destroy MSBuild process: ${pid}`);
return;
}
console.log(`Nuked ${name} with PID: ${pid}`);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc