remark-github
Advanced tools
Comparing version 7.0.1 to 7.0.2
@@ -11,3 +11,3 @@ 'use strict'; | ||
module.exports = attacher; | ||
module.exports = github; | ||
@@ -17,2 +17,11 @@ /* Hide process use from browserify. */ | ||
/* Load `fs` and `path` if available. */ | ||
var fs; | ||
var path; | ||
try { | ||
fs = require('fs'); | ||
path = require('path'); | ||
} catch (err) {} | ||
/* Username may only contain alphanumeric characters or | ||
@@ -32,8 +41,5 @@ * single hyphens, and cannot begin or end with a hyphen. | ||
/* Match a repo from a git / github URL. */ | ||
var REPOSITORY = new RegExp( | ||
'(?:^|/(?:repos/)?)' + REPO + '(?=\\.git|[\\/#@]|$)', 'i' | ||
); | ||
var REPOSITORY = new RegExp('(?:^|/(?:repos/)?)' + REPO + '(?=\\.git|[\\/#@]|$)', 'i'); | ||
/* Attacher. */ | ||
function attacher(options) { | ||
function github(options) { | ||
var settings = options || {}; | ||
@@ -49,4 +55,3 @@ var repository = settings.repository; | ||
try { | ||
// eslint-disable-next-line import/no-dynamic-require | ||
pack = require(require('path').resolve(proc.cwd(), 'package.json')); | ||
pack = JSON.parse(fs.readFileSync(path.join(proc.cwd(), 'package.json'))); | ||
} catch (err) { | ||
@@ -94,52 +99,49 @@ pack = {}; | ||
/** | ||
* Transformer. | ||
* | ||
* @param {Node} tree - Root node. | ||
*/ | ||
function transformer(tree) { | ||
visit(tree, 'link', function (node) { | ||
var link = parse(node); | ||
var children; | ||
var base; | ||
var comment; | ||
visit(tree, 'link', visitor); | ||
} | ||
if (!link) { | ||
return; | ||
} | ||
function visitor(node) { | ||
var link = parse(node); | ||
var children; | ||
var base; | ||
var comment; | ||
comment = link.comment ? ' (comment)' : ''; | ||
if (!link) { | ||
return; | ||
} | ||
if (link.project !== repository.project) { | ||
base = link.user + '/' + link.project; | ||
} else if (link.user === repository.user) { | ||
base = ''; | ||
} else { | ||
base = link.user; | ||
} | ||
comment = link.comment ? ' (comment)' : ''; | ||
if (link.page === parse.COMMIT) { | ||
children = []; | ||
if (link.project !== repository.project) { | ||
base = link.user + '/' + link.project; | ||
} else if (link.user === repository.user) { | ||
base = ''; | ||
} else { | ||
base = link.user; | ||
} | ||
if (base) { | ||
children.push({type: 'text', value: base + '@'}); | ||
} | ||
if (link.page === parse.COMMIT) { | ||
children = []; | ||
children.push({type: 'inlineCode', value: abbr(link.reference)}); | ||
if (base) { | ||
children.push({type: 'text', value: base + '@'}); | ||
} | ||
if (link.comment) { | ||
children.push({type: 'text', value: comment}); | ||
} | ||
} else { | ||
base += '#'; | ||
children.push({type: 'inlineCode', value: abbr(link.reference)}); | ||
children = [{ | ||
type: 'text', | ||
value: base + abbr(link.reference) + comment | ||
}]; | ||
if (link.comment) { | ||
children.push({type: 'text', value: comment}); | ||
} | ||
} else { | ||
base += '#'; | ||
node.children = children; | ||
}); | ||
children = [{ | ||
type: 'text', | ||
value: base + abbr(link.reference) + comment | ||
}]; | ||
} | ||
node.children = children; | ||
} | ||
} |
{ | ||
"name": "remark-github", | ||
"version": "7.0.1", | ||
"version": "7.0.2", | ||
"description": "Auto-link references like in GitHub issues, PRs, and comments", | ||
@@ -19,3 +19,3 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/wooorm/remark-github", | ||
"repository": "wooorm/remark-github", | ||
"bugs": "https://github.com/wooorm/remark-github/issues", | ||
@@ -26,2 +26,6 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
], | ||
"files": [ | ||
"index.js", | ||
"lib" | ||
], | ||
"dependencies": { | ||
@@ -34,6 +38,2 @@ "is-alphabetical": "^1.0.0", | ||
}, | ||
"files": [ | ||
"index.js", | ||
"lib" | ||
], | ||
"devDependencies": { | ||
@@ -43,4 +43,4 @@ "browserify": "^14.0.0", | ||
"nyc": "^11.0.2", | ||
"remark": "^7.0.0", | ||
"remark-cli": "^3.0.0", | ||
"remark": "^8.0.0", | ||
"remark-cli": "^4.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
@@ -47,0 +47,0 @@ "tape": "^4.4.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
27338
722