Skip to content

Commit 80c7b33

Browse files
authored
Merge pull request #4848 from DSpace/backport-4841-to-dspace-9_x
[Port dspace-9_x] Fix 'sync-i18n' script source file access
2 parents 387744e + 1bc8618 commit 80c7b33

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

scripts/sync-i18n-files.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ function parseCliInput() {
3838
.usage('([-d <output-dir>] [-s <source-file>]) || (-t <target-file> (-i | -o <output>) [-s <source-file>])')
3939
.parse(process.argv);
4040

41-
if (!program.targetFile) {
41+
const sourceFile = program.opts().sourceFile;
42+
43+
if (!program.targetFile) {
4244
fs.readdirSync(projectRoot(LANGUAGE_FILES_LOCATION)).forEach(file => {
43-
if (!program.sourceFile.toString().endsWith(file)) {
45+
if (!sourceFile.toString().endsWith(file)) {
4446
const targetFileLocation = projectRoot(LANGUAGE_FILES_LOCATION + "/" + file);
45-
console.log('Syncing file at: ' + targetFileLocation + ' with source file at: ' + program.sourceFile);
47+
console.log('Syncing file at: ' + targetFileLocation + ' with source file at: ' + sourceFile);
4648
if (program.outputDir) {
4749
if (!fs.existsSync(program.outputDir)) {
4850
fs.mkdirSync(program.outputDir);
@@ -67,7 +69,7 @@ function parseCliInput() {
6769
console.log(program.outputHelp());
6870
process.exit(1);
6971
}
70-
if (!checkIfFileExists(program.sourceFile)) {
72+
if (!checkIfFileExists(sourceFile)) {
7173
console.error('Path of source file is not valid.');
7274
console.log(program.outputHelp());
7375
process.exit(1);
@@ -101,7 +103,7 @@ function syncFileWithSource(pathToTargetFile, pathToOutputFile) {
101103
targetLines.push(line.trim());
102104
}));
103105
progressBar.update(10);
104-
const sourceFile = readFileIfExists(program.sourceFile);
106+
const sourceFile = readFileIfExists(program.opts().sourceFile);
105107
sourceFile.toString().split("\n").forEach((function (line) {
106108
sourceLines.push(line.trim());
107109
}));

0 commit comments

Comments
 (0)