Skip to content

Commit

Permalink
Add test that ensure all files in source directory use .d.ts extens…
Browse files Browse the repository at this point in the history
…ion (#264)
  • Loading branch information
Hirotaka Tagawa authored Sep 17, 2021
1 parent 6b18d3a commit 50a7d55
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"node": ">=12.20"
},
"scripts": {
"test": "xo && tsd && tsc"
"test": "xo && tsd && tsc && node script/test/source-files-extension.js"
},
"files": [
"index.d.ts",
Expand Down
26 changes: 26 additions & 0 deletions script/test/source-files-extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable unicorn/prefer-module */
const fs = require('fs');
const process = require('process');

const checkSourceFilesExtension = async () => {
try {
const files = await fs.promises.readdir('source');

let hasIncorrectFileExtension = false;
for (const file of files) {
if (!file.endsWith('.d.ts')) {
hasIncorrectFileExtension = true;
console.error(`source/${file} extension should be \`.d.ts\`.`);
}
}

if (hasIncorrectFileExtension) {
process.exitCode = 1;
}
} catch (error) {
console.error(error);
process.exitCode = 1;
}
};

checkSourceFilesExtension();

0 comments on commit 50a7d55

Please sign in to comment.