gulpfile.vscode.win32.js 2.1 KB
Newer Older
J
Joao Moreno 已提交
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

const gulp = require('gulp');
9 10 11 12
const path = require('path');
const assert = require('assert');
const cp = require('child_process');
const _ = require('lodash');
J
Joao Moreno 已提交
13
const util = require('./lib/util');
14 15
const pkg = require('../package.json');
const product = require('../product.json');
J
Joao Moreno 已提交
16

17 18 19 20
const repoPath = path.dirname(__dirname);
const buildPath = path.join(path.dirname(repoPath), 'VSCode-win32');
const issPath = path.join(__dirname, 'win32', 'code.iss');
const innoSetupPath = path.join(path.dirname(path.dirname(require.resolve('innosetup-compiler'))), 'bin', 'ISCC.exe');
J
Joao Moreno 已提交
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
function packageInnoSetup(iss, options, cb) {
	options = options || {};

	const definitions = options.definitions || {};
	const defs = _(definitions)
		.forEach((value, key) => assert(typeof value === 'string', `Missing value for '${ key }' in Inno Setup package step`))
		.map((value, key) => `/d${ key }=${ value }`)
		.value();

	const args = [iss]
		.concat(defs);

	cp.spawn(innoSetupPath, args, { stdio: 'inherit' })
		.on('error', cb)
		.on('exit', () => cb(null));
}

function buildWin32Setup(cb) {
	const definitions = {
		NameLong: product.nameLong,
		NameShort: product.nameShort,
		DirName: product.win32DirName,
		Version: pkg.version,
		RawVersion: pkg.version.replace(/-\w+$/, ''),
		NameVersion: product.win32NameVersion,
		ExeBasename: product.nameShort,
		RegValueName: product.win32RegValueName,
		AppMutex: product.win32MutexName,
		AppId: product.win32AppId,
		AppUserId: product.win32AppUserModelId,
		SourceDir: buildPath,
		RepoDir: repoPath
	};

	packageInnoSetup(issPath, { definitions }, cb);
J
Joao Moreno 已提交
57 58 59
}

gulp.task('clean-vscode-win32-setup', util.rimraf('.build/win32/setup'));
60
gulp.task('vscode-win32-setup', ['clean-vscode-win32-setup', 'vscode-win32-min'], buildWin32Setup);