Skip to content

Commit df0aa46

Browse files
committed
Relative links
1 parent b861b92 commit df0aa46

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

dist/index.js

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as fs from 'fs';
2+
import * as path from 'path';
23
import AdmZip from 'adm-zip';
34
import axios from 'axios';
45
import {toPlatformPath} from '@actions/core';
@@ -19,8 +20,12 @@ const downloadZipAndUnzip = async (zipUrl: string, destination: string): Promise
1920
return entries;
2021
};
2122

23+
const generateRelativeFileLink = (currentFilePath: string, destinationFilePath: string): string => {
24+
return path.relative(path.dirname(currentFilePath), destinationFilePath);
25+
};
26+
2227
const baseName = (filePath: string): string => {
2328
return filePath.split('/').pop() || filePath;
2429
};
2530

26-
export {downloadZipAndUnzip, baseName};
31+
export {downloadZipAndUnzip, generateRelativeFileLink, baseName};

src/writer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {Logger} from './logger';
33
import {Config, CredentialsConfig} from './config';
44
import {toPlatformPath} from '@actions/core';
55
import {LanguagesModel} from '@crowdin/crowdin-api-client/out/languages';
6+
import {generateRelativeFileLink} from './utils';
67

78
export class Writer {
89
private placeholderStart = '<!-- README-TRANSLATE-LANGUAGES-START -->';
@@ -61,7 +62,9 @@ export class Writer {
6162
let languages: string[] = [];
6263

6364
this.projectLanguages.map(language => {
64-
languages.push(`[${language.name}](${this.config.destination}/README.${language.locale}.md)`);
65+
const link = `${this.config.destination}/README.${language.locale}.md`;
66+
67+
languages.push(`[${language.name}](${generateRelativeFileLink(this.config.file, link)}))}`);
6568
});
6669

6770
return languages.join(' | ');

0 commit comments

Comments
 (0)