mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Script: delete empty tscparams
This commit is contained in:
parent
e7c111c4b7
commit
6af7535f03
40
scripts/delete-tscparams.ts
Normal file
40
scripts/delete-tscparams.ts
Normal file
@ -0,0 +1,40 @@
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const home = path.join(__dirname, '..');
|
||||
|
||||
function forEachTypingDir(callback: (fullPath: string, dirName: string) => void) {
|
||||
fs.readdir(home, (err, dirs) => {
|
||||
if (err) throw err;
|
||||
for (const dir of dirs) {
|
||||
const fullPath = path.join(home, dir);
|
||||
fs.lstat(fullPath, (err, stats) => {
|
||||
if (err) throw err;
|
||||
if (stats.isDirectory()) {
|
||||
callback(fullPath, dir);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
forEachTypingDir(typingPath => {
|
||||
fs.readdir(typingPath, (err, files) => {
|
||||
if(err) throw err;
|
||||
for(const file of files) {
|
||||
if (/tscparams$/.test(file)) {
|
||||
const fullPath = path.join(typingPath, file);
|
||||
|
||||
fs.readFile(fullPath, 'utf-8', (err, paramText) => {
|
||||
if(err) throw err;
|
||||
|
||||
if (paramText.length <= 2) {
|
||||
fs.unlink(fullPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user