Skip to content

Commit

Permalink
Merge pull request #10 from the-markup/newlines
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
BatMiles authored Sep 24, 2024
2 parents 84949dd + 2e3b193 commit 4018045
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"devDependencies": {
"@types/jest": "^27.5.1",
"@types/node": "^20.16.1",
"@types/progress": "^2.0.7",
"@types/tough-cookie": "^4.0.5",
"jest": "^28.1.0",
"ts-jest": "^28.0.2",
Expand Down
14 changes: 10 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,30 @@ if (!fs.existsSync(urlsPath)) {
exit();
}
const urls = fs.readFileSync(urlsPath, "utf8");
const urlsList = urls.split("\n");
const urlsList = urls.trim().split(/\r?\n|\r|\n/g);
const outDir = "../outputs";

let progressBar = progress.create({ total: urlsList.length });

let failedUrls: string[] = [];

// Make output directory
if (!fs.existsSync(outDir)) {
fs.mkdirSync(outDir);
if (!fs.existsSync(join(__dirname, outDir))) {
fs.mkdirSync(join(__dirname, outDir));
}

// Gather scans
(async () => {
for (let url of urlsList) {
console.log(`Scanning ${url} ...`);
const urlObj = new URL(url);
const folderStructure = `${outDir}/${urlObj.hostname}`;
let folderStructure = `${outDir}/${urlObj.hostname}`;

if (fs.existsSync(join(__dirname, folderStructure))) {
const timestamp = Date.now();
folderStructure += `-${timestamp}`;
}

const config = {
headless: true,
outDir: join(__dirname, folderStructure),
Expand Down

0 comments on commit 4018045

Please sign in to comment.