in app/exec/extension/_lib/vsix-writer.ts [273:351]
private addResourceStrings(vsix: zip): Promise<void[]> {
// Make sure locRoot is set, that it refers to a directory, and
// iterate each subdirectory of that.
if (!this.settings.locRoot) {
return Promise.resolve<void[]>(null);
}
let stringsPath = path.resolve(this.settings.locRoot);
// Check that --loc-root exists and is a directory.
return exists(stringsPath)
.then<boolean>(exists => {
if (exists) {
return promisify(lstat)(stringsPath).then(stats => {
if (stats.isDirectory()) {
return true;
}
});
} else {
return false;
}
})
.then<void[]>(stringsFolderExists => {
if (!stringsFolderExists) {
return Promise.resolve<void[]>(null);
}
// stringsPath exists and is a directory - read it.
return promisify(readdir)(stringsPath).then((files: string[]) => {
let promises: Promise<void>[] = [];
files.forEach(languageTag => {
var filePath = path.join(stringsPath, languageTag);
let promise = promisify(lstat)(filePath).then(fileStats => {
if (fileStats.isDirectory()) {
// We're under a language tag directory within locRoot. Look for
// resources.resjson and use that to generate manfiest files
let resourcePath = path.join(filePath, "resources.resjson");
exists(resourcePath).then(exists => {
if (exists) {
// A resources.resjson file exists in <locRoot>/<language_tag>/
return promisify(readFile)(resourcePath, "utf8").then(contents => {
let resourcesObj = JSON.parse(contents);
// For each language, go through each builder and generate its
// localized resources.
this.manifestBuilders.forEach(builder => {
const locFiles = builder.getLocResult(resourcesObj, null);
locFiles.forEach(locFile => {});
});
let locGen = new LocPrep.LocKeyGenerator(null);
// let splitRes = locGen.splitIntoVsoAndVsixResourceObjs(resourcesObj);
// let locManifestPath = languageTag + "/" + VsixWriter.VSO_MANIFEST_FILENAME;
// vsix.file(toZipItemName(locManifestPath), this.getVsoManifestString(splitRes.vsoResources));
// this.vsixManifest.PackageManifest.Assets[0].Asset.push({
// "$": {
// Lang: languageTag,
// Type: "Microsoft.VisualStudio.Services.Manifest",
// Path: locManifestPath,
// Addressable: "true",
// "d:Source": "File"
// }
// });
// let builder = new xml.Builder(VsixWriter.DEFAULT_XML_BUILDER_SETTINGS);
// let vsixLangPackStr = builder.buildObject(splitRes.vsixResources);
// vsix.file(toZipItemName(languageTag + "/Extension.vsixlangpack"), vsixLangPackStr);
});
} else {
return Promise.resolve<void>(null);
}
});
}
});
promises.push(promise);
});
return Promise.all(promises);
});
});
}