Skip to content

Commit

Permalink
Add "make" script to package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
besoeasy committed Dec 16, 2023
1 parent 0917040 commit 9db58f4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
39 changes: 39 additions & 0 deletions make.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const fs = require('fs');
const { exec } = require('child_process');

const extraname = "coleos-"

function generateRandomFileName() {
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
let randomName = '';
for (let i = 0; i < 8; i++) {
randomName += characters.charAt(Math.floor(Math.random() * characters.length));
}
return `components/unsorted/${extraname}${randomName}.html`; // Updated path
}

function createHTMLFile() {
const fileName = generateRandomFileName();
const htmlContent = '<div> </div>';

fs.writeFile(fileName, htmlContent, (err) => {
if (err) {
console.error('Error creating HTML file:', err);
} else {
console.log(`Created HTML file: ${fileName}`);
openInVSCode(fileName);
}
});
}

function openInVSCode(fileName) {
exec(`code ${fileName}`, (err, stdout, stderr) => {
if (err) {
console.error('Error opening file in VS Code:', err);
} else {
console.log(`Opened ${fileName} in VS Code`);
}
});
}

createHTMLFile();
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "tailwind-components",
"main": "index.js",
"scripts": {
"make": "node make.js",
"copy": "rm -rf dist && mkdir -p dist && cp -r components/* dist",
"build": "npm run copy && node build.js && npx prettier --print-width 200 --write dist "
},
Expand All @@ -26,4 +27,4 @@
"devDependencies": {
"prettier": "^3.1.0"
}
}
}

0 comments on commit 9db58f4

Please sign in to comment.