-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
995e1b1
commit c10df70
Showing
3 changed files
with
65 additions
and
1 deletion.
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
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,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')) | ||
} |
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,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) | ||
} | ||
) |