New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aocrunner

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aocrunner - npm Package Compare versions

Comparing version 0.2.14 to 0.2.15

6

lib/actions/dev.js

@@ -38,6 +38,4 @@ import fs from "fs";

console.log(stripIndent`
Type:
${boldMagenta("fetch")} or ${boldMagenta("f")} - to fetch the input
${boldMagenta("send")} or ${boldMagenta("s")} - to send the solution
Type ${boldMagenta("fetch")} or ${boldMagenta("f")} - to fetch the input
Type ${boldMagenta("send")} or ${boldMagenta("s")} - to send the solution
`);

@@ -44,0 +42,0 @@ runSolution(dayNum, indexFile);

@@ -5,7 +5,7 @@ import { spawnSync } from "child_process";

console.log(kleur.blue(`
= Day ${day} =`.padEnd(40, "=") + "\n"));
-- Day ${day} `.padEnd(40, "-") + "\n"));
spawnSync("node", [path], {
stdio: "inherit"
});
console.log(kleur.blue("\n" + "=".repeat(39)));
console.log(kleur.blue("\n".padEnd(40, "-")));
};

@@ -12,0 +12,0 @@ var runSolution_default = runSolution;

@@ -32,3 +32,3 @@ var __defProp = Object.defineProperty;

"@types/node": "^16.11.6",
aocrunner: "^0.2.14"
aocrunner: "^0.2.15"
},

@@ -35,0 +35,0 @@ dependencies: {},

@@ -7,3 +7,3 @@ declare type Tests = {

declare type Solutions = {
part1: {
part1?: {
solution: Solution;

@@ -10,0 +10,0 @@ tests?: Tests;

@@ -21,2 +21,10 @@ import fs from "fs";

};
const runSolution = async (solution, input) => {
const t0 = process.hrtime.bigint();
const result = await solution(input);
const t1 = process.hrtime.bigint();
const time = (Number(t1 - t0) / 1e6).toFixed(3);
console.log(`Part 1 (in ${time}ms):`);
console.dir(result);
};
const runAsync = async (solutions, inputFile) => {

@@ -31,3 +39,8 @@ var _a, _b;

const input = fs.readFileSync(inputFile).toString();
console.log(input);
if (solutions.part1) {
await runSolution(solutions.part1.solution, input);
}
if (solutions.part2) {
await runSolution(solutions.part2.solution, input);
}
};

@@ -37,4 +50,8 @@ const run = (solutions, inputFile) => {

const callerFile = getCallerFile().replace(/(file:\\\\)|(file:\/\/)/, "");
const dir = path.parse(callerFile).dir;
inputFile = path.join(dir, "input.txt");
const dir = path.parse(callerFile).dir.split(path.sep);
const lastDist = dir.lastIndexOf("dist");
if (lastDist !== -1) {
dir[lastDist] = "src";
}
inputFile = path.join(...dir, "input.txt");
console.log(inputFile);

@@ -41,0 +58,0 @@ }

{
"name": "aocrunner",
"version": "0.2.14",
"version": "0.2.15",
"description": "Advent of Code runner",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -49,6 +49,4 @@ import fs from "fs"

console.log(stripIndent`
Type:
${boldMagenta("fetch")} or ${boldMagenta("f")} - to fetch the input
${boldMagenta("send")} or ${boldMagenta("s")} - to send the solution
Type ${boldMagenta("fetch")} or ${boldMagenta("f")} - to fetch the input
Type ${boldMagenta("send")} or ${boldMagenta("s")} - to send the solution
`)

@@ -55,0 +53,0 @@

@@ -5,9 +5,9 @@ import { spawnSync } from "child_process"

const runSolution = (day: number, path: string) => {
console.log(kleur.blue(`\n= Day ${day} =`.padEnd(40, "=") + "\n"))
console.log(kleur.blue(`\n-- Day ${day} `.padEnd(40, "-") + "\n"))
spawnSync("node", [path], {
stdio: "inherit",
})
console.log(kleur.blue("\n" + "=".repeat(39)))
console.log(kleur.blue("\n".padEnd(40, "-")))
}
export default runSolution

@@ -20,3 +20,3 @@ import type { Setup } from "../types/common"

"@types/node": "^16.11.6",
aocrunner: "^0.2.14",
aocrunner: "^0.2.15",
},

@@ -23,0 +23,0 @@ dependencies: {},

@@ -11,3 +11,3 @@ import fs from "fs"

type Solutions = {
part1: {
part1?: {
solution: Solution

@@ -39,2 +39,12 @@ tests?: Tests

const runSolution = async (solution: Solution, input: string) => {
const t0 = process.hrtime.bigint()
const result = await solution(input)
const t1 = process.hrtime.bigint()
const time = (Number(t1 - t0) / 1e6).toFixed(3)
console.log(`Part 1 (in ${time}ms):`)
console.dir(result)
}
const runAsync = async (solutions: Solutions, inputFile: string) => {

@@ -51,3 +61,9 @@ if (solutions?.part1?.tests) {

console.log(input)
if (solutions.part1) {
await runSolution(solutions.part1.solution, input)
}
if (solutions.part2) {
await runSolution(solutions.part2.solution, input)
}
}

@@ -58,4 +74,11 @@

const callerFile = getCallerFile().replace(/(file:\\\\)|(file:\/\/)/, "")
const dir = path.parse(callerFile).dir
inputFile = path.join(dir, "input.txt")
const dir = path.parse(callerFile).dir.split(path.sep)
const lastDist = dir.lastIndexOf("dist")
if (lastDist !== -1) {
dir[lastDist] = "src"
}
inputFile = path.join(...dir, "input.txt")
console.log(inputFile)

@@ -62,0 +85,0 @@ }

@@ -1,3 +0,32 @@

const hello = "Hello World!"
import run from "aocrunner"
export default hello
const parseInput = (rawInput: string) => rawInput
const solution1 = async (rawInput: string) => {
const input = parseInput(rawInput)
// Solution:
}
const solution2 = async (rawInput: string) => {
const input = parseInput(rawInput)
// Solution:
}
run({
part1: {
tests: [
// { input: ``, expected: "" },
// { input: ``, expected: "" },
],
solution: solution1,
},
part2: {
tests: [
// { input: ``, expected: "" },
// { input: ``, expected: "" },
],
solution: solution2,
},
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc