Skip to content

Commit

Permalink
chore: add dist cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Cesarato committed Jun 10, 2021
1 parent 836d6c8 commit c197040
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
],
"main": "dist/commonjs/index.js",
"module": "dist/module/index.js",
"react-native": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib",
Expand All @@ -42,7 +41,7 @@
"homepage": "https://github.com/marcocesarato/react-native-big-list#readme",
"license": "GPL-3.0-or-later",
"scripts": {
"prepare": "bob build",
"prepare": "bob build && node scripts/dist.js",
"lint": "eslint --ignore-path .gitignore \"./lib/*.{js,jsx}\"",
"prettify": "prettier --write \"./**/*.{ts,tsx,js,jsx,json,md}\"",
"format": "yarpm run prettify && yarpm run lint --fix",
Expand All @@ -60,6 +59,7 @@
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-native": "^3.11.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"glob": "^7.1.7",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
"prettier": "^2.3.0",
Expand Down
21 changes: 21 additions & 0 deletions scripts/dist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const fs = require("fs");
const glob = require("glob");
const prettier = require("prettier");

function clean(str) {
return prettier.format(str.replace(/\*\/(\r?\n)+/g, "*/\n"), {
parser: "babel",
});
}

console.log("Cleaning distribution...");

glob(process.cwd() + "/dist/**/*.{js,jsx,ts,tsx}", {}, (error, files) => {
if (error) console.log(error);
files.forEach((file) => {
const contents = fs.readFileSync(file).toString();
fs.writeFile(file, clean(contents), (e) => {
if (e) console.log(e);
});
});
});
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2609,7 +2609,7 @@ glob-parent@^5.1.0, glob-parent@^5.1.2:
dependencies:
is-glob "^4.0.1"

glob@^7.0.0, glob@^7.1.3, glob@^7.1.6:
glob@^7.0.0, glob@^7.1.3, glob@^7.1.6, glob@^7.1.7:
version "7.1.7"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90"
integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==
Expand Down

0 comments on commit c197040

Please sign in to comment.