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
Provenance
- Commit
8ebe396- Tree
d073314- Author
Andrey Sitnik <andrey@sitnik.ru>- Committer
Andrey Sitnik <andrey@sitnik.ru>- Parent
ec43400
2 files changed+35 added−32 removed
modified:test/bruteforce+34 added-31 removed
1 #!/usr/bin/env node2 3-var fs = require("fs");4-var spawnSync = require("child_process").spawnSync;3+var fs = require('fs')4+var spawnSync = require('child_process').spawnSync5 6-var filePath = process.argv[2];6+var filePath = process.argv[2]7 var bestResult = {8- value: "",8+ value: '',9 size: Infinity10-};11-var lastString = "";10+}11+var lastString = ''12 13-function shuffle(a) {14- var j, x, i;13+function 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 }23 24-function saveFirstString() {25- var data = fs.readFileSync(filePath, "utf8")26- data.replace(/[A-Za-z0-9~_]{58}/g, function(match) {24+function saveFirstString () {25+ var data = fs.readFileSync(filePath, 'utf8')26+ data.replace(/[A-Za-z0-9~_]{58}/g, function (match) {27 lastString = match28- });28+ })29 }30 31-function shuffleStringInFile() {32- var data = fs.readFileSync(filePath, "utf8")31+function shuffleStringInFile () {32+ var data = fs.readFileSync(filePath, 'utf8')33 34- 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+ })38 39- fs.writeFileSync(filePath + "", result, "utf8")39+ fs.writeFileSync(filePath + '', result, 'utf8')40 }41 42-function 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];42+function 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]48 49- 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 }55 56 saveFirstString()6 unmodified linesmodified:package.json+1 added-1 removed
52 unmodified lines53545556575758596061112 unmodified linesExpand all52 unmodified lines "lint-staged": "lint-staged", "spellcheck": "yarn docs && yaspeller-ci *.md docs/*.html", "clean": "rimraf docs/ coverage/", "docs": "jsdoc -d docs *.js async/*.js", "lint": "eslint-ci *.js async/*.js test/*.js test/**/*.js", "lint": "eslint-ci *.js async/*.js test/{benchmark,bruteforce} test/*.js test/**/*.js", "test": "jest --coverage && yarn lint && size-limit && yarn spellcheck", "start": "webpack-dev-server --config test/demo/webpack.config" }, "size-limit": [112 unmodified linesExpand all