This repository has been archived by the owner on Jun 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support/cleanup removal of unused js files + linting * fix flow
- Loading branch information
Showing
258 changed files
with
98 additions
and
30,772 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,56 @@ | ||
const { rm } = require("fs"); | ||
|
||
const exec = require("child_process").exec; | ||
|
||
/* eslint-disable no-console */ | ||
|
||
async function executeAsync(command) { | ||
return new Promise((resolve, reject) => { | ||
exec(command, (error, stdout, stderr) => { | ||
if (error) { | ||
reject(error); | ||
} else if (stderr) { | ||
reject(stderr); | ||
} else { | ||
resolve(stdout); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
async function listTsJsFilesPairs() { | ||
const jsFilesPath = {}; | ||
const jsTsPairs = []; | ||
await executeAsync('git ls-files | grep -e ".\\.js$"').then(res => | ||
res.split("\n").map(path => (jsFilesPath[path] = true)), | ||
); | ||
return executeAsync('git ls-files | grep -e ".\\.ts$" -e ".\\.tsx$"') | ||
.then(res => | ||
res.split("\n").forEach(path => { | ||
const beforeExtensionPath = path | ||
.split(".") | ||
.slice(0, -1) | ||
.join("."); | ||
const jsFilePath = `${beforeExtensionPath}.js`; | ||
if (jsFilesPath[jsFilePath]) { | ||
jsTsPairs.push({ | ||
tsFilePath: path, | ||
jsFilePath, | ||
}); | ||
} | ||
}), | ||
) | ||
.then(() => jsTsPairs); | ||
} | ||
|
||
async function removeJS() { | ||
const pairs = await listTsJsFilesPairs(); | ||
|
||
pairs.forEach(({ jsFilePath }) => { | ||
rm(jsFilePath); | ||
}); | ||
|
||
return true; | ||
} | ||
|
||
removeJS().then(() => console.log("JS files removed")); |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.