Skip to content

Commit

Permalink
Automatically update modules.list
Browse files Browse the repository at this point in the history
  • Loading branch information
Bizarrus committed Sep 3, 2024
1 parent 345d9a0 commit fee3573
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .builder/build.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Archiver from 'archiver';
import FS from 'fs';
import OS from 'os';

const exclude = [ 'modules.packages' ];

let modules = [];
let count = 0;

FS.readdirSync('../').forEach(file => {
/* Ignoring hidden files */
if(file.substr(0, 1) === '.') {
Expand All @@ -16,6 +20,7 @@ FS.readdirSync('../').forEach(file => {

/* Only use Directorys */
if(FS.statSync('../' + file).isDirectory()) {
++count;
console.log('[INFO] Found Module:', file);

const archive= Archiver('zip', {
Expand All @@ -29,6 +34,7 @@ FS.readdirSync('../').forEach(file => {

archive.directory('../' + file, true).on('finish', () => {
console.info('[INFO] Packed: ', file, '~> modules.packages/' + file + '.zip');
modules.push(file);
}).on('error', error => {
console.error('[ERROR]', error);
}).on('warning', warning => {
Expand All @@ -37,4 +43,20 @@ FS.readdirSync('../').forEach(file => {

archive.finalize();
}
});

let _watcher = setInterval(() => {
if(modules.length == count) {
clearInterval(_watcher);
console.info('[INFO] Update modules.list');
modules.sort();

FS.writeFile('../modules.list', modules.join(OS.EOL), error => {
if (error) {
console.error('[ERROR]', error);
} else {
console.info('[INFO] modules.list updated with ', modules.length, ' Modules');
}
});
}
});

0 comments on commit fee3573

Please sign in to comment.