Skip to content
Myr

Fix test script linting

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Andrey Sitnik · committed by Andrey Sitnik · parent ec43400 · Browse files · 2 files+35 added−32 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+35 added−32 removed

  • tests:+34 added−31 removed
  • other:+1 added−1 removed

2 files+35 added−32 removed

modified:test/bruteforce+34 added-31 removed
1#!/usr/bin/env node23var fs = require("fs");4var spawnSync = require("child_process").spawnSync;3var fs = require('fs')4var spawnSync = require('child_process').spawnSync56var filePath = process.argv[2];6var filePath = process.argv[2]7var bestResult = {8 value: "",8 value: '',9 size: Infinity10};11var lastString = "";10}11var lastString = ''1213function shuffle(a) {14 var j, x, i;13function shuffle (a) {14 var j, x, i15 for (i = a.length - 1; i > 0; i--) {16 j = Math.floor(Math.random() * (i + 1));17 x = a[i];18 a[i] = a[j];19 a[j] = x;16 j = Math.floor(Math.random() * (i + 1))17 x = a[i]18 a[i] = a[j]19 a[j] = x20 }21 return a;21 return a22}2324function saveFirstString() {25 var data = fs.readFileSync(filePath, "utf8")26 data.replace(/[A-Za-z0-9~_]{58}/g, function(match) {24function saveFirstString () {25 var data = fs.readFileSync(filePath, 'utf8')26 data.replace(/[A-Za-z0-9~_]{58}/g, function (match) {27 lastString = match28 });28 })29}3031function shuffleStringInFile() {32 var data = fs.readFileSync(filePath, "utf8")31function shuffleStringInFile () {32 var data = fs.readFileSync(filePath, 'utf8')3334 var result = data.replace(/[A-Za-z0-9~_]{64}/g, function(match) {35 lastString = shuffle(match.split("")).join("");36 return lastString;37 });34 var result = data.replace(/[A-Za-z0-9~_]{64}/g, function (match) {35 lastString = shuffle(match.split('')).join('')36 return lastString37 })3839 fs.writeFileSync(filePath + "", result, "utf8")39 fs.writeFileSync(filePath + '', result, 'utf8')40}4142function checkSize() {43 var output = spawnSync("npx", ["size-limit", filePath]).output44 var size = output.toString("utf8").match(/Package size: ([0-9]+)/);45 if (size && size[1] != 0 && size[1] < bestResult.size) {46 bestResult.value = lastString;47 bestResult.size = size[1];42function checkSize () {43 var output = spawnSync('npx', ['size-limit', filePath]).output44 var size = output.toString('utf8').match(/Package size: ([0-9]+)/)45 if (size && size[1] !== 0 && size[1] < bestResult.size) {46 bestResult.value = lastString47 bestResult.size = size[1]4849 console.log('New best string has been founded: ' + bestResult.value + ' | size: ' + bestResult.size);49 console.log(50 'New best string has been founded: ' + bestResult.value +51 ' | size: ' + bestResult.size52 )53 }54}5556saveFirstString()
6 unmodified lines
modified:package.json+1 added-1 removed