Skip to content

Commit

Permalink
Update for remark@6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 21, 2016
1 parent 5fc1492 commit 3963fba
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 185 deletions.
38 changes: 18 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ module.exports = attacher;
var exists = fs.existsSync;
var parse = url.parse;

/* Constants. */
var NS = 'remark-validate-links';

/**
* Get the `pathname` of `uri`, if applicable.
*
Expand Down Expand Up @@ -89,17 +86,17 @@ function getClosest(pathname, references) {
}

/**
* Utilitity to warn `warning` for each node in `nodes`,
* Utilitity to warn `reason` for each node in `nodes`,
* on `file`.
*
* @param {File} file - Virtual file.
* @param {Array.<Node>} nodes - Offending nodes.
* @param {string} message - Message.
* @param {string} reason - Message.
*/
function warnAll(file, nodes, message) {
function warnAll(file, nodes, reason) {
nodes.forEach(function (node) {
var warning = file.warn(message, node);
warning.source = 'remark-validate-links';
var message = file.message(reason, node);
message.source = message.ruleId = 'remark-validate-links';
});
}

Expand All @@ -117,8 +114,8 @@ function warnAll(file, nodes, message) {
*/
function gatherReferences(file, tree, project) {
var cache = {};
var filePath = file.filePath();
var directory = file.directory;
var filePath = file.path;
var dirname = file.dirname;
var getDefinition;
var prefix = '';

Expand Down Expand Up @@ -158,7 +155,7 @@ function gatherReferences(file, tree, project) {
link = filePath + uri.hash;
uri = parse(link);
} else {
link = urljoin(directory || './', link);
link = urljoin(dirname, link);
if (uri.hash) {
link += uri.hash;
}
Expand Down Expand Up @@ -238,8 +235,8 @@ function gatherReferences(file, tree, project) {
* @param {File} file - Set of virtual files.
*/
function validate(exposed, file) {
var references = file.namespace(NS).references;
var filePath = file.filePath();
var references = file.data.remarkValidateLinksReferences;
var filePath = file.path;
var reference;
var nodes;
var real;
Expand Down Expand Up @@ -300,7 +297,7 @@ function completer(set, done) {
var exposed = {};

set.valueOf().forEach(function (file) {
var landmarks = file.namespace(NS).landmarks;
var landmarks = file.data.remarkValidateLinksLandmarks;

if (landmarks) {
exposed = xtend(exposed, landmarks);
Expand All @@ -309,7 +306,7 @@ function completer(set, done) {

set.valueOf().forEach(function (file) {
/* istanbul ignore else - stdin */
if (file.filePath()) {
if (file.path) {
validate(exposed, file);
}
});
Expand Down Expand Up @@ -337,8 +334,8 @@ function transformerFactory(project, fileSet) {
* @param {File} file - Virtual file.
*/
function transformer(ast, file) {
var filePath = file.filePath();
var space = file.namespace(NS);
var filePath = file.path;
var space = file.data;
var links = [];
var landmarks = {};
var references;
Expand Down Expand Up @@ -379,8 +376,8 @@ function transformerFactory(project, fileSet) {
}
});

space.references = references;
space.landmarks = landmarks;
space.remarkValidateLinksReferences = references;
space.remarkValidateLinksLandmarks = landmarks;
}

return transformer;
Expand Down Expand Up @@ -408,7 +405,8 @@ function attacher(remark, options, fileSet) {
* given. */
if (!repo) {
try {
pack = require(path.resolve(process.cwd(), 'package.json'));
pack = fileSet.files[0].cwd;
pack = require(path.resolve(pack, 'package.json'));
} catch (err) {
pack = {};
}
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"github-url-to-object": "^2.1.0",
"mdast-util-definitions": "^1.0.0",
"propose": "0.0.5",
"remark-slug": "^4.1.0",
"remark-slug": "^4.2.1",
"unist-util-visit": "^1.0.0",
"urljoin": "^0.1.5",
"xtend": "^4.0.1"
Expand All @@ -34,9 +34,9 @@
],
"devDependencies": {
"execa": "^0.4.0",
"nyc": "^7.0.0",
"remark": "^5.0.0",
"remark-cli": "^1.0.0",
"nyc": "^8.1.0",
"remark": "^6.0.0",
"remark-cli": "^2.0.0",
"remark-comment-config": "^4.0.0",
"remark-github": "^5.0.0-alpha.1",
"remark-lint": "^4.0.0",
Expand Down Expand Up @@ -68,7 +68,7 @@
"functions": 100,
"branches": 100
},
"remarkConfig": {
"remarkConfig-": {
"output": true,
"plugins": [
"comment-config",
Expand Down
Loading

0 comments on commit 3963fba

Please sign in to comment.