-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
39 lines (30 loc) · 1.18 KB
/
build.js
File metadata and controls
39 lines (30 loc) · 1.18 KB
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
const fs = require('fs');
const path = require('path');
const archiver = require('archiver');
const pluginName = 'com.jase.steambp.sdPlugin';
const output = fs.createWriteStream(path.join(__dirname, `${pluginName}.streamDeckPlugin`));
const archive = archiver('zip', { zlib: { level: 9 } });
output.on('close', () => {
console.log(`Plugin built: ${archive.pointer()} total bytes`);
console.log(`File: ${pluginName}.streamDeckPlugin`);
});
archive.on('error', (err) => {
throw err;
});
archive.pipe(output);
// Add all files with the plugin folder name as prefix
// Stream Deck expects: pluginName.streamDeckPlugin/pluginName/manifest.json
const prefix = pluginName + '/';
archive.file('manifest.json', { name: prefix + 'manifest.json' });
archive.file('package.json', { name: prefix + 'package.json' });
archive.directory('bin/', prefix + 'bin');
archive.directory('propertyinspector/', prefix + 'propertyinspector');
// Add images if they exist
if (fs.existsSync('images')) {
archive.directory('images/', prefix + 'images');
}
// Add node_modules only if they exist
if (fs.existsSync('node_modules')) {
archive.directory('node_modules/', prefix + 'node_modules');
}
archive.finalize();