-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
706d114
commit 648aa69
Showing
3 changed files
with
74 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
type ResultType = { | ||
js : Record<string , boolean> | ||
ts : Record<string , boolean> | ||
} | ||
|
||
const result: ResultType = {js:{} , ts:{}} | ||
|
||
const readThroughDirectory = (directory: string): void => { | ||
const __directoryPath = directory | ||
const files = fs.readdirSync(__directoryPath); | ||
files.forEach((file) => { | ||
const filePath = path.join(__directoryPath, file); | ||
const stats = fs.statSync(filePath); | ||
if (stats.isDirectory()) { | ||
readThroughDirectory(filePath); | ||
return | ||
} | ||
|
||
if(filePath.endsWith('.js')){ | ||
const name = filePath.split('.') | ||
name.pop() | ||
result.js[name.join('.')] = true | ||
} | ||
|
||
if(filePath.endsWith('.d.ts')){ | ||
const name = filePath.split('.') | ||
name.pop() | ||
name.pop() | ||
result.ts[name.join('.')] = true | ||
} | ||
|
||
}); | ||
|
||
Object.keys(result.js).forEach(file => { | ||
if(!result.ts[file]){ | ||
throw new Error(`Declaration File Missing for ${file}.js`) | ||
} | ||
}) | ||
|
||
}; | ||
|
||
readThroughDirectory(path.join(process.env.INIT_CWD ?? '', './bin')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters