/
gulpfile.ts
40 lines (35 loc) · 2.02 KB
/
gulpfile.ts
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process';
import * as fs from 'fs';
import * as gulp from 'gulp';
import * as path from 'path';
import { gulp_installAzureAccount, gulp_installResourceGroups, gulp_webpack } from '@microsoft/vscode-azext-dev';
async function prepareForWebpack(): Promise<void> {
const mainJsPath: string = path.join(__dirname, 'main.js');
let contents: string = fs.readFileSync(mainJsPath).toString();
contents = contents
.replace('out/src/extension', 'dist/extension.bundle')
.replace(', true /* ignoreBundle */', '');
fs.writeFileSync(mainJsPath, contents);
}
async function cleanReadme(): Promise<void> {
const readmePath: string = path.join(__dirname, 'README.md');
let data: string = fs.readFileSync(readmePath).toString();
data = data.replace(/<!-- region exclude-from-marketplace -->.*?<!-- endregion exclude-from-marketplace -->/gis, '');
fs.writeFileSync(readmePath, data);
}
async function setAzCopyExePermissions(): Promise<void> {
if (process.platform === 'darwin') {
cp.exec(`chmod u+x ${path.join(__dirname, 'node_modules/@azure-tools/azcopy-darwin/dist/bin/azcopy_darwin_amd64')}`);
} else if (process.platform === 'linux') {
cp.exec(`chmod u+x ${path.join(__dirname, 'node_modules/@azure-tools/azcopy-linux/dist/bin/azcopy_linux_amd64')}`);
}
}
exports['webpack-dev'] = gulp.series(prepareForWebpack, () => gulp_webpack('development'));
exports['webpack-prod'] = gulp.series(prepareForWebpack, () => gulp_webpack('production'));
exports.preTest = gulp.series(gulp_installAzureAccount, gulp_installResourceGroups);
exports.cleanReadme = cleanReadme;
exports.setAzCopyExePermissions = setAzCopyExePermissions;