Skip to content

Commit

Permalink
tools: update Markdown linter to be cross-platform
Browse files Browse the repository at this point in the history
Prior to this commit, the dependencies were not
matching the build procedure. This has been
corrected and it has the added benefit of being
able to be built on Windows as well.

* continue using `rollup` rather than `ncc`
* do not require `fs-event`s for non-macOS
* use `npx` and `shx` for cross-platform building
* ensure `lint-md-rollup` runs before `lint-md`

PR-URL: #31239
Reviewed-By: Rich Trott <rtrott@gmail.com>
Derek Lewis authored and codebytere committed Feb 17, 2020
1 parent fda97fa commit 95d509e
Showing 5 changed files with 44,790 additions and 127 deletions.
44,428 changes: 44,426 additions & 2 deletions tools/lint-md.js

Large diffs are not rendered by default.

421 changes: 303 additions & 118 deletions tools/node-lint-md-cli-rollup/package-lock.json

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions tools/node-lint-md-cli-rollup/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
{
"name": "node-lint-md-cli-rollup",
"description": "remark packaged for Node.js Markdown linting",
"version": "2.0.1",
"version": "2.0.2",
"devDependencies": {
"@zeit/ncc": "^0.21.0"
"@rollup/plugin-commonjs": "^11.0.1",
"@rollup/plugin-json": "^4.0.1",
"@rollup/plugin-node-resolve": "^7.0.0",
"rollup": "^1.30.1",
"shx": "^0.3.2"
},
"dependencies": {
"markdown-extensions": "^1.1.1",
"remark": "^11.0.2",
"remark-lint": "^6.0.5",
"remark-preset-lint-node": "^1.11.0",
"remark-preset-lint-node": "^1.12.0",
"unified-args": "^7.1.0"
},
"main": "src/cli-entry.js",
"main": "dist/index.js",
"scripts": {
"build": "ncc build -m",
"build-node": "npm run build && cp dist/index.js ../lint-md.js"
"build": "npx rollup -c",
"build-node": "npm run build && npx shx cp dist/index.js ../lint-md.js"
}
}
51 changes: 51 additions & 0 deletions tools/node-lint-md-cli-rollup/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';

const resolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const json = require('@rollup/plugin-json');

module.exports = {
input: 'src/cli-entry.js',
output: {
file: 'dist/index.js',
format: 'cjs',
sourcemap: false,
},
external: [
'stream',
'path',
'module',
'util',
'tty',
'os',
'fs',
'fsevents',
'events',
'assert',
],
plugins: [
{
name: 'brute-replace',
transform(code, id) {
const normID = id.replace(__dirname, '').replace(/\\+/g, '/');
if (normID === '/node_modules/concat-stream/index.js') {
return code.replace('\'readable-stream\'', '\'stream\'');
}
if (normID === '/node_modules/unified-args/lib/options.js') {
return code.replace('\'./schema\'', '\'./schema.json\'');
}
if (normID === '/node_modules/chokidar/lib/fsevents-handler.js' &&
process.platform !== 'darwin') {
return code.replace(
'fsevents = require(\'fsevents\');', 'fsevents = undefined;'
);
}
}
},
json({
preferConst: true
}),
resolve(), // tells Rollup how to find date-fns in node_modules
commonjs(), // Converts date-fns to ES modules
]
};
1 change: 0 additions & 1 deletion tools/node-lint-md-cli-rollup/src/cli-entry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env node
'use strict';

// To aid in future maintenance, this layout closely matches remark-cli/cli.js.

0 comments on commit 95d509e

Please sign in to comment.