Files
Michael Cartner b9c60b07dc Initial commit
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com>
Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com>
Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com>
Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com>
Co-Authored-By: Johan  <4934465+joolsus@users.noreply.github.com>
Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com>
Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
2024-01-26 11:52:55 +01:00

33 lines
996 B
JavaScript

const fs = require('fs');
const path = require('path');
const publishDir = path.join(__dirname, '../publish');
const publishDistDir = path.join(__dirname, '../publish/dist/');
// Delete the publish folder if it exists
if (fs.existsSync(publishDir)) {
fs.rmdirSync(publishDir, { recursive: true, force: true });
}
// Create the publish folders
fs.mkdirSync(publishDistDir, { recursive: true });
// Copy over the wanted files
const files = ['dist/main.js', 'package.json', 'README.md', 'LICENSE'];
files.forEach((file) => {
const fromPath = path.join(__dirname, '..', file);
const toPath = path.join(publishDir, file);
fs.copyFileSync(fromPath, toPath);
});
// Clean up package.json
const packageFilePath = path.join(publishDir, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageFilePath));
delete packageJson.scripts;
delete packageJson.dependencies;
delete packageJson.devDependencies;
fs.writeFileSync(packageFilePath, JSON.stringify(packageJson, null, 2));