Last active
September 28, 2022 16:14
-
-
Save giovanniantonaccio/360dd3ab05ed455a5c2d500f9fe59aec to your computer and use it in GitHub Desktop.
React scanner config file
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
#!/usr/bin/env node | |
const scanner = require("react-scanner"); | |
const os = require("os"); | |
const path = require("path"); | |
const getLastItemFromPath = (thePath) => thePath.substring(thePath.lastIndexOf("/") + 1); | |
const userHomePath = os.homedir(); | |
const projectPath = process.cwd(); | |
const projectFolderName = getLastItemFromPath(projectPath); | |
const reportName = `${projectFolderName}-${Date.now()}.json`; | |
const reportPath = path.join(userHomePath, "react-scanner-reports", reportName); | |
const config = { | |
crawlFrom: "./src", | |
includeSubComponents: true, | |
// importedFrom: "lib-name", | |
globs: ["**/!(*.test|*.spec).@(js|ts)?(x)"], | |
// processors: [["raw-report", { outputTo: "./my-report.json" }]], | |
// components: { Button: true }, | |
processors: [["count-components-and-props", { outputTo: reportPath }]], | |
}; | |
scanner | |
.run(config, "", "programmatic") | |
.then(() => console.log("Report saved in: ", reportPath)) | |
.catch((err) => console.log(err)); |
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
{ | |
"name": "run-js-with-npx-from-gist", | |
"version": "1.0.0", | |
"dependencies": { | |
"react-scanner": "^1.0.4" | |
}, | |
"bin": "./index.js" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment