Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/lib/inlineMeta.js
3520 views
1
"use strict";
2
var __importDefault = (this && this.__importDefault) || function (mod) {
3
return (mod && mod.__esModule) ? mod : { "default": mod };
4
};
5
Object.defineProperty(exports, "__esModule", { value: true });
6
exports.inlineMeta = inlineMeta;
7
/*---------------------------------------------------------------------------------------------
8
* Copyright (c) Microsoft Corporation. All rights reserved.
9
* Licensed under the MIT License. See License.txt in the project root for license information.
10
*--------------------------------------------------------------------------------------------*/
11
const event_stream_1 = __importDefault(require("event-stream"));
12
const path_1 = require("path");
13
const packageJsonMarkerId = 'BUILD_INSERT_PACKAGE_CONFIGURATION';
14
// TODO in order to inline `product.json`, more work is
15
// needed to ensure that we cover all cases where modifications
16
// are done to the product configuration during build. There are
17
// at least 2 more changes that kick in very late:
18
// - a `darwinUniversalAssetId` is added in`create-universal-app.ts`
19
// - a `target` is added in `gulpfile.vscode.win32.js`
20
// const productJsonMarkerId = 'BUILD_INSERT_PRODUCT_CONFIGURATION';
21
function inlineMeta(result, ctx) {
22
return result.pipe(event_stream_1.default.through(function (file) {
23
if (matchesFile(file, ctx)) {
24
let content = file.contents.toString();
25
let markerFound = false;
26
const packageMarker = `${packageJsonMarkerId}:"${packageJsonMarkerId}"`; // this needs to be the format after esbuild has processed the file (e.g. double quotes)
27
if (content.includes(packageMarker)) {
28
content = content.replace(packageMarker, JSON.stringify(JSON.parse(ctx.packageJsonFn())).slice(1, -1) /* trim braces */);
29
markerFound = true;
30
}
31
// const productMarker = `${productJsonMarkerId}:"${productJsonMarkerId}"`; // this needs to be the format after esbuild has processed the file (e.g. double quotes)
32
// if (content.includes(productMarker)) {
33
// content = content.replace(productMarker, JSON.stringify(JSON.parse(ctx.productJsonFn())).slice(1, -1) /* trim braces */);
34
// markerFound = true;
35
// }
36
if (markerFound) {
37
file.contents = Buffer.from(content);
38
}
39
}
40
this.emit('data', file);
41
}));
42
}
43
function matchesFile(file, ctx) {
44
for (const targetPath of ctx.targetPaths) {
45
if (file.basename === (0, path_1.basename)(targetPath)) { // TODO would be nicer to figure out root relative path to not match on false positives
46
return true;
47
}
48
}
49
return false;
50
}
51
//# sourceMappingURL=inlineMeta.js.map
52