generated from theripper93/FoundryVTT-Module-Template
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcreate-release.js
41 lines (33 loc) · 1.13 KB
/
create-release.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const fs = require('fs');
const path = require('path');
const zip = require('zip-dir');
const moduleJsonPath = path.join(__dirname, 'module.json');
fs.readFile(moduleJsonPath, 'utf8', (err, data) => {
if (err) {
console.error(`Error reading module.json: ${err}`);
return;
}
try {
const moduleInfo = JSON.parse(data);
const version = moduleInfo.version;
const id = moduleInfo.id;
const zipFileName = `${id}-${version}.zip`;
const distFolderPath = path.join(__dirname, 'dist');
const filesToInclude = [
"module.json","styles", "index.js", "index.js.map", "templates", "languages", "assets"
];
const options = {
saveTo: path.join(distFolderPath, zipFileName),
filter: (path) => filesToInclude.some((item) => path.includes(item)),
};
zip(__dirname, options, (err) => {
if (err) {
console.error(`Error creating zip: ${err}`);
return;
}
console.log(`Release zip "${zipFileName}" created in "dist" folder.`);
});
} catch (parseError) {
console.error(`Error parsing module.json: ${parseError}`);
}
});