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