forked from joshuef/peruse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-pack.js
57 lines (41 loc) · 1.39 KB
/
post-pack.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env node
const exec = require( 'child_process' ).exec;
const path = require( 'path' );
const fs = require( 'fs-extra' );
const archiver = require( 'archiver' );
const pkg = require( './package.json' );
const targetDir = path.resolve( __dirname, 'release' );
const platform = process.platform;
const OSX = 'darwin';
const LINUX = 'linux';
const WINDOWS = 'win32';
const pkgName = pkg.name;
let PLATFORM_NAME;
let CONTAINING_FOLDER;
if ( platform === OSX )
{
CONTAINING_FOLDER = path.resolve( targetDir, 'mac' );
PLATFORM_NAME = 'osx';
}
if ( platform === LINUX )
{
CONTAINING_FOLDER = path.resolve( targetDir, 'linux-unpacked' );
PLATFORM_NAME = LINUX;
}
if ( platform === WINDOWS )
{
CONTAINING_FOLDER = path.resolve( targetDir, 'win-unpacked' );
PLATFORM_NAME = 'win';
}
const RELEASE_FOLDER_NAME = `${pkgName}-v${pkg.version}-${PLATFORM_NAME}-x64`;
// add version file
fs.outputFileSync( path.resolve( CONTAINING_FOLDER, 'version' ), pkg.version );
// remove licenses
const removalArray = ['LICENSE.electron.txt', 'LICENSES.chromium.html', 'LICENSE'];
removalArray.forEach( ( file ) =>
{
fs.removeSync( `${CONTAINING_FOLDER}/${file}` );
} );
console.log( 'Renaming package to:', path.resolve( targetDir, `${RELEASE_FOLDER_NAME}` ) );
// rename release folder
fs.moveSync( CONTAINING_FOLDER, path.resolve( targetDir, `${RELEASE_FOLDER_NAME}` ), { overwrite: true } );