Small tweaks
This commit is contained in:
parent
67be8c8670
commit
fda5017a66
4 changed files with 3571 additions and 27 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
||||||
*doctest*
|
*doctest*
|
||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
|
3536
package-lock.json
generated
Normal file
3536
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json.schemastore.org/package",
|
"$schema": "http://json.schemastore.org/package",
|
||||||
"name": "doctest-ts-improved",
|
"name": "doctest-ts-improved",
|
||||||
"version": "0.8.0",
|
"version": "0.8.4",
|
||||||
"description": "doctest support for typescript with Mocha",
|
"description": "doctest support for typescript with Mocha",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -11,7 +11,8 @@
|
||||||
"build": "tsc && chmod 755 dist/main.js",
|
"build": "tsc && chmod 755 dist/main.js",
|
||||||
"doctest:watch": "ts-node src/main.ts --tape --watch {src,test}/*.ts | while read file; do echo tape $file; ts-node $file | tap-diff; done",
|
"doctest:watch": "ts-node src/main.ts --tape --watch {src,test}/*.ts | while read file; do echo tape $file; ts-node $file | tap-diff; done",
|
||||||
"test": "ts-node src/main.ts examples/ && ts-node src/main.ts src/ && mocha --require ts-node/register examples/*.ts src/*.ts",
|
"test": "ts-node src/main.ts examples/ && ts-node src/main.ts src/ && mocha --require ts-node/register examples/*.ts src/*.ts",
|
||||||
"prettier": "rm -v -f {src,test}/*doctest.ts && prettier --list-different --write src/*ts* test/*ts*"
|
"prettier": "rm -v -f {src,test}/*doctest.ts && prettier --list-different --write src/*ts* test/*ts*",
|
||||||
|
"publish": "npm run build && npm publish"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
55
src/main.ts
55
src/main.ts
|
@ -14,7 +14,7 @@ function readDirRecSync(path: string, maxDepth = 999): string[] {
|
||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
// Subdirectory
|
// Subdirectory
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
result.push(...ScriptUtils.readDirRecSync(fullEntry, maxDepth - 1))
|
result.push(...readDirRecSync(fullEntry, maxDepth - 1))
|
||||||
} else {
|
} else {
|
||||||
result.push(fullEntry)
|
result.push(fullEntry)
|
||||||
}
|
}
|
||||||
|
@ -22,31 +22,36 @@ function readDirRecSync(path: string, maxDepth = 999): string[] {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function main(){
|
function main() {
|
||||||
|
|
||||||
const args = process.argv
|
|
||||||
console.log(args.join(","))
|
|
||||||
const directory = args[2].replace(/\/$/, "")
|
|
||||||
if(directory === "--require"){
|
|
||||||
console.error("Probably running the testsuite, detects '--require' as second argument. Quitting now")
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(directory === undefined){
|
|
||||||
console.log("Usage: doctest-ts-improved <directory under test>. This will automatically scan recursively for '.ts'-files, excluding 'node_modules' '*.doctest.ts'-files")
|
|
||||||
}
|
|
||||||
|
|
||||||
const files = readDirRecSync(directory).filter(p => !p.startsWith("./node_modules") && !p.endsWith(".doctest.ts"))
|
const args = process.argv
|
||||||
const noTests : string[] = []
|
console.log(args.join(","))
|
||||||
for (const file of files) {
|
const directory = args[2].replace(/\/$/, "")
|
||||||
const generated = new TestCreator(file).createTest()
|
if (directory === "--require") {
|
||||||
if(generated === 0){
|
console.error("Probably running the testsuite, detects '--require' as second argument. Quitting now")
|
||||||
noTests.push(file)
|
return;
|
||||||
}else{
|
}
|
||||||
console.log("Generated tests for "+file+" ("+generated+" tests found)")
|
if (directory === undefined) {
|
||||||
|
console.log("Usage: doctest-ts-improved <directory under test>. This will automatically scan recursively for '.ts'-files, excluding 'node_modules' '*.doctest.ts'-files")
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = readDirRecSync(directory)
|
||||||
|
.filter(p => p.endsWith(".ts"))
|
||||||
|
.filter(p => p.indexOf("/node_modules/") < 0 && !p.endsWith(".doctest.ts"))
|
||||||
|
const noTests: string[] = []
|
||||||
|
for (let i = 0; i < files.length; i++){
|
||||||
|
const file = files[i];
|
||||||
|
process.stdout.write(`\r (${i}/${files.length}) inspecting ${file} \r`)
|
||||||
|
const generated = new TestCreator(file).createTest()
|
||||||
|
if (generated === 0) {
|
||||||
|
noTests.push(file)
|
||||||
|
} else {
|
||||||
|
console.log("Generated tests for " + file + " (" + generated + " tests found)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (noTests.length > 0) {
|
||||||
|
console.log("No tests found in: " + noTests.join(", "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(noTests.length > 0){
|
|
||||||
console.log("No tests found in: "+noTests.join(", "))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
main()
|
main()
|
Loading…
Add table
Reference in a new issue