mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 05:37:53 +00:00
Merge pull request #1031 from balena-io/roman/use-resin-lint
Use resin-lint for mocha tests check
This commit is contained in:
commit
e1fdafddfc
@ -7,4 +7,10 @@
|
||||
"resin-lint --typescript --no-prettier",
|
||||
"git add"
|
||||
],
|
||||
"test/**/*.coffee": [
|
||||
"resin-lint --tests"
|
||||
],
|
||||
"test/**/*.ts": [
|
||||
"resin-lint --typescript --no-prettier --tests"
|
||||
],
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// This script checks if files in test directory don't contain describe.only or it.only statements
|
||||
// to ensure that an accidental commit does not prevent all the tests to be run.
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const testsDir = './test';
|
||||
const srcFileExtensions = ['.ts', '.coffee', '.js'];
|
||||
|
||||
const checkPattern = /((describe)|(it))\.only/;
|
||||
|
||||
const checkDirRecursively = (dirPath, func) =>
|
||||
fs.readdirSync(dirPath, {withFileTypes: true}).forEach((file) => {
|
||||
const filePath = path.join(dirPath, file.name);
|
||||
if (file.isDirectory()) {
|
||||
checkDirRecursively(filePath, func);
|
||||
return;
|
||||
}
|
||||
for (let ext of srcFileExtensions) {
|
||||
if (file.name.endsWith(ext)) {
|
||||
const content = fs.readFileSync(filePath, {encoding: 'utf8'});
|
||||
func(filePath, content);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let errorsFound = false;
|
||||
|
||||
checkDirRecursively(testsDir, (fileName, content) => {
|
||||
const lines = content.split('\n');
|
||||
for (let ln = 0; ln < lines.length; ln++) {
|
||||
const res = checkPattern.exec(lines[ln]);
|
||||
if (res) {
|
||||
errorsFound = true;
|
||||
console.error(`File ${fileName}, line ${ln}: found ${res[0]}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (errorsFound) {
|
||||
process.exit(1);
|
||||
}
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -8783,9 +8783,9 @@
|
||||
}
|
||||
},
|
||||
"resin-lint": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/resin-lint/-/resin-lint-3.0.4.tgz",
|
||||
"integrity": "sha512-TVxY7SaJqQRZcLubJn5yO49db/M4eRXRr7FbA4xwqSYxQSqujNql8ThMoNMoRrx+1F7NrfSdhIsLEaMqCea4VA==",
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/resin-lint/-/resin-lint-3.1.0.tgz",
|
||||
"integrity": "sha512-bipsVrhMBtoegrBdJf/6NMQke4g8xmZENSu0fBU1KvxLXNhGPQkmobY7vVmP47BeD0m0Zdv9yrEc43w2S+kRWA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/bluebird": "^3.5.26",
|
||||
|
@ -100,7 +100,7 @@
|
||||
"prettier": "1.17.0",
|
||||
"pretty-ms": "^4.0.0",
|
||||
"request": "^2.51.0",
|
||||
"resin-lint": "^3.0.0",
|
||||
"resin-lint": "^3.1.0",
|
||||
"resin-register-device": "^3.0.0",
|
||||
"resumable-request": "^2.0.0",
|
||||
"rimraf": "^2.6.2",
|
||||
@ -121,7 +121,7 @@
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged && automation/lint-mocha-tests.js"
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user