mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Removed async copy in rename function (#16209)
* Removed async copy in rename function * added comments and removed async
This commit is contained in:
@@ -266,18 +266,6 @@ function refreshLangpacks() {
|
|||||||
if (languageId === "zh-tw") {
|
if (languageId === "zh-tw") {
|
||||||
languageId = "zh-hant";
|
languageId = "zh-hant";
|
||||||
}
|
}
|
||||||
//remove extensions not part of ADS.
|
|
||||||
if (fs.existsSync(translationDataFolder)) {
|
|
||||||
let totalExtensions = fs.readdirSync(path.join(translationDataFolder, 'extensions'));
|
|
||||||
for (let extensionTag in totalExtensions) {
|
|
||||||
let extensionFileName = totalExtensions[extensionTag];
|
|
||||||
let xlfPath = path.join(location, `${languageId}`, extensionFileName.replace('.i18n.json', '.xlf'));
|
|
||||||
if (!(fs.existsSync(xlfPath) || VSCODEExtensions.indexOf(extensionFileName.replace('.i18n.json', '')) !== -1)) {
|
|
||||||
let filePath = path.join(translationDataFolder, 'extensions', extensionFileName);
|
|
||||||
rimraf.sync(filePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(`Importing translations for ${languageId} from '${location}' to '${translationDataFolder}' ...`);
|
console.log(`Importing translations for ${languageId} from '${location}' to '${translationDataFolder}' ...`);
|
||||||
let translationPaths = [];
|
let translationPaths = [];
|
||||||
gulp.src(path.join(location, languageId, '**', '*.xlf'))
|
gulp.src(path.join(location, languageId, '**', '*.xlf'))
|
||||||
@@ -356,6 +344,8 @@ function renameVscodeLangpacks() {
|
|||||||
}
|
}
|
||||||
let locADSFolder = path.join('.', 'i18n', `ads-language-pack-${langId}`);
|
let locADSFolder = path.join('.', 'i18n', `ads-language-pack-${langId}`);
|
||||||
let locVSCODEFolder = path.join('.', 'i18n', `vscode-language-pack-${langId}`);
|
let locVSCODEFolder = path.join('.', 'i18n', `vscode-language-pack-${langId}`);
|
||||||
|
let translationDataFolder = path.join(locVSCODEFolder, 'translations');
|
||||||
|
let xlfFolder = path.join('.', 'resources', 'xlf');
|
||||||
try {
|
try {
|
||||||
fs.statSync(locVSCODEFolder);
|
fs.statSync(locVSCODEFolder);
|
||||||
}
|
}
|
||||||
@@ -363,13 +353,26 @@ function renameVscodeLangpacks() {
|
|||||||
console.log('vscode pack is not in ADS yet: ' + langId);
|
console.log('vscode pack is not in ADS yet: ' + langId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
gulp.src(path.join(locADSFolder, '*.md'))
|
// Delete extension files in vscode language pack that are not in ADS.
|
||||||
.pipe(rename(filepath => filepath.dirname = ''))
|
if (fs.existsSync(translationDataFolder)) {
|
||||||
.pipe(gulp.dest(locVSCODEFolder))
|
let totalExtensions = fs.readdirSync(path.join(translationDataFolder, 'extensions'));
|
||||||
.on('end', () => {
|
for (let extensionTag in totalExtensions) {
|
||||||
rimraf.sync(locADSFolder);
|
let extensionFileName = totalExtensions[extensionTag];
|
||||||
fs.renameSync(locVSCODEFolder, locADSFolder);
|
let xlfPath = path.join(xlfFolder, `${langId}`, extensionFileName.replace('.i18n.json', '.xlf'));
|
||||||
|
if (!(fs.existsSync(xlfPath) || VSCODEExtensions.indexOf(extensionFileName.replace('.i18n.json', '')) !== -1)) {
|
||||||
|
let filePath = path.join(translationDataFolder, 'extensions', extensionFileName);
|
||||||
|
rimraf.sync(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Get list of md files in ADS langpack, to copy to vscode langpack prior to renaming.
|
||||||
|
let globArray = glob.sync(path.join(locADSFolder, '*.md'));
|
||||||
|
//Copy files to vscode langpack, then remove the ADS langpack, and finally rename the vscode langpack to match the ADS one.
|
||||||
|
globArray.forEach(element => {
|
||||||
|
fs.copyFileSync(element, path.join(locVSCODEFolder, path.parse(element).base));
|
||||||
});
|
});
|
||||||
|
rimraf.sync(locADSFolder);
|
||||||
|
fs.renameSync(locVSCODEFolder, locADSFolder);
|
||||||
}
|
}
|
||||||
console.log("Langpack Rename Completed.");
|
console.log("Langpack Rename Completed.");
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
|||||||
@@ -287,20 +287,6 @@ export function refreshLangpacks(): Promise<void> {
|
|||||||
languageId = "zh-hant";
|
languageId = "zh-hant";
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove extensions not part of ADS.
|
|
||||||
if (fs.existsSync(translationDataFolder)) {
|
|
||||||
let totalExtensions = fs.readdirSync(path.join(translationDataFolder, 'extensions'));
|
|
||||||
for (let extensionTag in totalExtensions) {
|
|
||||||
let extensionFileName = totalExtensions[extensionTag];
|
|
||||||
let xlfPath = path.join(location, `${languageId}`, extensionFileName.replace('.i18n.json', '.xlf'))
|
|
||||||
if (!(fs.existsSync(xlfPath) || VSCODEExtensions.indexOf(extensionFileName.replace('.i18n.json', '')) !== -1)) {
|
|
||||||
let filePath = path.join(translationDataFolder, 'extensions', extensionFileName);
|
|
||||||
rimraf.sync(filePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
console.log(`Importing translations for ${languageId} from '${location}' to '${translationDataFolder}' ...`);
|
console.log(`Importing translations for ${languageId} from '${location}' to '${translationDataFolder}' ...`);
|
||||||
let translationPaths: any = [];
|
let translationPaths: any = [];
|
||||||
gulp.src(path.join(location, languageId, '**', '*.xlf'))
|
gulp.src(path.join(location, languageId, '**', '*.xlf'))
|
||||||
@@ -380,6 +366,8 @@ export function renameVscodeLangpacks(): Promise<void> {
|
|||||||
}
|
}
|
||||||
let locADSFolder = path.join('.', 'i18n', `ads-language-pack-${langId}`);
|
let locADSFolder = path.join('.', 'i18n', `ads-language-pack-${langId}`);
|
||||||
let locVSCODEFolder = path.join('.', 'i18n', `vscode-language-pack-${langId}`);
|
let locVSCODEFolder = path.join('.', 'i18n', `vscode-language-pack-${langId}`);
|
||||||
|
let translationDataFolder = path.join(locVSCODEFolder, 'translations');
|
||||||
|
let xlfFolder = path.join('.', 'resources', 'xlf');
|
||||||
try {
|
try {
|
||||||
fs.statSync(locVSCODEFolder);
|
fs.statSync(locVSCODEFolder);
|
||||||
}
|
}
|
||||||
@@ -387,13 +375,28 @@ export function renameVscodeLangpacks(): Promise<void> {
|
|||||||
console.log('vscode pack is not in ADS yet: ' + langId);
|
console.log('vscode pack is not in ADS yet: ' + langId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
gulp.src(path.join(locADSFolder, '*.md'))
|
// Delete extension files in vscode language pack that are not in ADS.
|
||||||
.pipe(rename(filepath => filepath.dirname = ''))
|
if (fs.existsSync(translationDataFolder)) {
|
||||||
.pipe(gulp.dest(locVSCODEFolder))
|
let totalExtensions = fs.readdirSync(path.join(translationDataFolder, 'extensions'));
|
||||||
.on('end', () => {
|
for (let extensionTag in totalExtensions) {
|
||||||
rimraf.sync(locADSFolder);
|
let extensionFileName = totalExtensions[extensionTag];
|
||||||
fs.renameSync(locVSCODEFolder, locADSFolder);
|
let xlfPath = path.join(xlfFolder, `${langId}`, extensionFileName.replace('.i18n.json', '.xlf'))
|
||||||
});
|
if (!(fs.existsSync(xlfPath) || VSCODEExtensions.indexOf(extensionFileName.replace('.i18n.json', '')) !== -1)) {
|
||||||
|
let filePath = path.join(translationDataFolder, 'extensions', extensionFileName);
|
||||||
|
rimraf.sync(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get list of md files in ADS langpack, to copy to vscode langpack prior to renaming.
|
||||||
|
let globArray = glob.sync(path.join(locADSFolder, '*.md'));
|
||||||
|
|
||||||
|
//Copy files to vscode langpack, then remove the ADS langpack, and finally rename the vscode langpack to match the ADS one.
|
||||||
|
globArray.forEach(element => {
|
||||||
|
fs.copyFileSync(element, path.join(locVSCODEFolder,path.parse(element).base));
|
||||||
|
});
|
||||||
|
rimraf.sync(locADSFolder);
|
||||||
|
fs.renameSync(locVSCODEFolder, locADSFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Langpack Rename Completed.");
|
console.log("Langpack Rename Completed.");
|
||||||
|
|||||||
Reference in New Issue
Block a user