Skip to content

Commit

Permalink
fixes #542
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Mar 12, 2021
1 parent 88c77f5 commit 83163ed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/main.ts
Expand Up @@ -87,12 +87,12 @@ module.exports = function (argv: string[]): void {
.option('--yarn', 'Use yarn instead of npm (default inferred from presence of yarn.lock or .yarnrc)')
.option('--no-yarn', 'Use npm instead of yarn (default inferred from lack of yarn.lock or .yarnrc)')
.option('--ignoreFile [path]', 'Indicate alternative .vscodeignore')
.option('--noGitHubIssueLinking', 'Prevent automatic expansion of GitHub-style issue syntax into links')
.option('--no-gitHubIssueLinking', 'Disable automatic expansion of GitHub-style issue syntax into links')
.option(
'--web',
'Experimental flag to enable publishing web extensions. Note: This is supported only for selected extensions.'
)
.action(({ out, githubBranch, baseContentUrl, baseImagesUrl, yarn, ignoreFile, noGitHubIssueLinking, web }) =>
.action(({ out, githubBranch, baseContentUrl, baseImagesUrl, yarn, ignoreFile, gitHubIssueLinking, web }) =>
main(
packageCommand({
packagePath: out,
Expand All @@ -101,7 +101,7 @@ module.exports = function (argv: string[]): void {
baseImagesUrl,
useYarn: yarn,
ignoreFile,
expandGitHubIssueLinks: noGitHubIssueLinking,
gitHubIssueLinking,
web,
})
)
Expand Down
27 changes: 13 additions & 14 deletions src/package.ts
Expand Up @@ -76,16 +76,16 @@ export interface IAsset {
}

export interface IPackageOptions {
cwd?: string;
packagePath?: string;
githubBranch?: string;
baseContentUrl?: string;
baseImagesUrl?: string;
useYarn?: boolean;
dependencyEntryPoints?: string[];
ignoreFile?: string;
expandGitHubIssueLinks?: boolean;
web?: boolean;
readonly cwd?: string;
readonly packagePath?: string;
readonly githubBranch?: string;
readonly baseContentUrl?: string;
readonly baseImagesUrl?: string;
readonly useYarn?: boolean;
readonly dependencyEntryPoints?: string[];
readonly ignoreFile?: string;
readonly gitHubIssueLinking?: boolean;
readonly web?: boolean;
}

export interface IProcessor {
Expand Down Expand Up @@ -421,7 +421,7 @@ export class MarkdownProcessor extends BaseProcessor {
private baseImagesUrl: string;
private isGitHub: boolean;
private repositoryUrl: string;
private expandGitHubIssueLinks: boolean;
private gitHubIssueLinking: boolean;

constructor(
manifest: Manifest,
Expand All @@ -438,8 +438,7 @@ export class MarkdownProcessor extends BaseProcessor {
this.baseImagesUrl = options.baseImagesUrl || options.baseContentUrl || (guess && guess.images);
this.repositoryUrl = guess && guess.repository;
this.isGitHub = isGitHubRepository(this.repositoryUrl);
this.expandGitHubIssueLinks =
typeof options.expandGitHubIssueLinks === 'boolean' ? options.expandGitHubIssueLinks : true;
this.gitHubIssueLinking = typeof options.gitHubIssueLinking === 'boolean' ? options.gitHubIssueLinking : true;
}

async onFile(file: IFile): Promise<IFile> {
Expand Down Expand Up @@ -506,7 +505,7 @@ export class MarkdownProcessor extends BaseProcessor {
return all.replace(link, urljoin(prefix, link));
});

if (this.isGitHub && this.expandGitHubIssueLinks) {
if (this.gitHubIssueLinking && this.isGitHub) {
const markdownIssueRegex = /(\s|\n)([\w\d_-]+\/[\w\d_-]+)?#(\d+)\b/g;
const issueReplace = (
all: string,
Expand Down
2 changes: 1 addition & 1 deletion src/test/package.test.ts
Expand Up @@ -1999,7 +1999,7 @@ describe('MarkdownProcessor', () => {
};

const root = fixture('readme');
const processor = new ReadmeProcessor(manifest, { expandGitHubIssueLinks: false });
const processor = new ReadmeProcessor(manifest, { gitHubIssueLinking: false });
const readme = {
path: 'extension/readme.md',
localPath: path.join(root, 'readme.github.md'),
Expand Down

0 comments on commit 83163ed

Please sign in to comment.