Files
azuredatastudio/build/lib/locFunc.js
Alex Ma 82e0ede921 Vsix build task for langpacks (#15489)
* added refreshlangpack command

* added beginning update-localization yml file, also changed langpack location in RLE

* added regex tester

* moved xlf files into new folder structure

* small change to update-localization

* added yaml script for gulp refresh

* added missing dash.

* added better update-localization yml file

* remove update-localization as its not necessary

* added small changes to langpack-compile

* remove upload sourcemaps and write version information

* added more languages

* added vsce packaging

* added automatic langpack handling

* added built locFunc

* fixed refresh-langpack-extension

* working langpack vsix generator made

* added langpacks to files in copyArtifacts and product-build-linux

* changed command to package-langpacks

* removed unnecessary language flags.

* invalid ADS extensions filter explained

* Fix for regex

* removed unnecessary fields to change, and removed langpack-compile

* added doc comments.

* moved xlf files back to old place.

* WIP translation redirect

* isolated vsix build task

* fixed spaces in locFunc.ts
2021-05-20 20:03:25 -07:00

50 lines
2.1 KiB
JavaScript

"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.packageLangpacksStream = void 0;
const es = require("event-stream");
const path = require("path");
const fs = require("fs");
const stats_1 = require("./stats");
const File = require("vinyl");
const glob = require("glob");
const rename = require("gulp-rename");
const root = path.dirname(path.dirname(__dirname));
// Modified packageLocalExtensionsStream from extensions.ts, but for langpacks.
function packageLangpacksStream() {
const langpackDescriptions = glob.sync('i18n/*/package.json')
.map(manifestPath => {
const langpackPath = path.dirname(path.join(root, manifestPath));
const langpackName = path.basename(langpackPath);
return { name: langpackName, path: langpackPath };
});
const builtLangpacks = langpackDescriptions.map(langpack => {
return fromLocalNormal(langpack.path)
.pipe(rename(p => p.dirname = `langpacks/${langpack.name}/${p.dirname}`));
});
return es.merge(builtLangpacks);
}
exports.packageLangpacksStream = packageLangpacksStream;
//copied from extensions.
function fromLocalNormal(extensionPath) {
const result = es.through();
const vsce = require('vsce');
vsce.listFiles({ cwd: extensionPath, packageManager: vsce.PackageManager.Yarn })
.then(fileNames => {
const files = fileNames
.map(fileName => path.join(extensionPath, fileName))
.map(filePath => new File({
path: filePath,
stat: fs.statSync(filePath),
base: extensionPath,
contents: fs.createReadStream(filePath)
}));
es.readArray(files).pipe(result);
})
.catch(err => result.emit('error', err));
return result.pipe(stats_1.createStatsStream(path.basename(extensionPath)));
}