Skip to content

Commit

Permalink
feat: fix scripts addscope missing
Browse files Browse the repository at this point in the history
  • Loading branch information
aminekun90 committed Jul 25, 2024
1 parent 995e1b1 commit c10df70
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "advanced-color-utils",
"name": "@aminekun90/advanced-color-utils",
"version": "1.0.1",
"description": "Unleash the full potential of color manipulation with the ColorUtils library! Designed for developers who need precise control over color processing",
"main": "dist/ColorUtils.js",
Expand All @@ -8,6 +8,7 @@
"start": "ts-node -r tsconfig-paths/register src/index.ts",
"test": "jest --no-cache --runInBand",
"test:cov": "jest --coverage --no-cache --runInBand",
"addscope": "node tools/packagejson name @aminekun90/advanced-color-utils",
"build": "tsc"
},
"author": "aminekun90",
Expand Down
38 changes: 38 additions & 0 deletions tools/cleanup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable */
const fs = require('fs')
const Path = require('path')
/* eslint-enable */

const allowedDirectories = [Path.join(__dirname, '../dist')]; // Define allowed directories

const deleteFolderRecursive = (dirPath) => {
const sanitizedPath = Path.resolve(dirPath);

if (!allowedDirectories.some(directory => sanitizedPath.includes(directory))) {
console.error('Invalid path.'); // Input path is not in the allowed directories
return;
}

if (fs.existsSync(sanitizedPath)) {
fs.readdirSync(sanitizedPath).forEach((file) => {
const curPath = Path.join(sanitizedPath, file);
if (fs.lstatSync(curPath).isDirectory()) {
deleteFolderRecursive(curPath);
} else {
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(sanitizedPath);
}
};

const folder = process.argv.slice(2)[0]

if (folder) {
deleteFolderRecursive(Path.join(__dirname, '../dist', folder))
} else {
deleteFolderRecursive(Path.join(__dirname, '../dist/cjs'))
deleteFolderRecursive(Path.join(__dirname, '../dist/esm'))
deleteFolderRecursive(Path.join(__dirname, '../dist/umd'))
deleteFolderRecursive(Path.join(__dirname, '../dist/types'))
}
25 changes: 25 additions & 0 deletions tools/packagejson.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* eslint-disable */
const fs = require('fs')
const Path = require('path')
const fileName = '../package.json'
const file = require(fileName)
/* eslint-enable */

const args = process.argv.slice(2)

for (let i = 0, l = args.length; i < l; i++) {
if (i % 2 === 0) {
file[args[i]] = args[i + 1]
}
}

fs.writeFile(
Path.join(__dirname, fileName),
JSON.stringify(file, null, 2),
(err) => {
if (err) {
return console.log(err)
}
console.log('Writing to ' + fileName)
}
)

0 comments on commit c10df70

Please sign in to comment.