Integrate the Acrolinx CLI as NPM Script

Make sure you're familiar with how to configure and run the CLI. We assume that your project already contains a CLI configuration file like .cli-config.json.

The Acrolinx CLI GitHub repository contains a working example package.json. We further assume that you've installed NodeJS and npm already.

Configure NPM

If you use further tools to process XUnit style test results, you just have to add the result-junit option (already set in CLI config file), and collect the test results:

acrolinx-cli -c .cli-config.json check

To make the build fail in case of issues in your files, we provide a node script to analyze the results: test-result.js.

The script needs to be referenced in the package.json:

  "scripts": {
    "acrolinx-check": "acrolinx-cli -c .cli-config.json check",
    "preacrolinx": "npm run acrolinx-check",
    "acrolinx": "node scripts/test-result.js"

You can start an Acrolinx check by running:

npm run acrolinx

If you want to check your file before a build starts, you can reference the script as pre script:

"prebuild": "npm run acrolinx",

The script will be executed each time you run:

npm run build


Example output of npm run acrolinx
C:\github\cli-demo>npm run acrolinx
> cli-demo@0.0.1 preacrolinx C:\github\cli-demo
> npm run acrolinx-check

> cli-demo@0.0.1 acrolinx-check C:\github\cli-demo
> acrolinx-cli -c .cli-config.json check

Batch ID: gen.cli.d6a60240-2b07-11e9-a4a9-05449bbe020a
You're signed in as "baseline-cli".
Check completed for: C:\github\cli-demo\samples\
Check completed for: C:\github\cli-demo\samples\test.txt
Check completed for: C:\github\cli-demo\
Check completed for:
Find the Content Analysis Dashboard here:

> cli-demo@0.0.1 acrolinx C:\github\cli-demo
> node scripts/test-result.js

Analyzing Acrolinx Results: ../results/result.json

54 (red) C:\github\cli-demo\samples\ (
70 (yellow) C:\github\cli-demo\samples\test.txt (
73 (yellow) (

Acrolinx: Please correct 3 files.

npm ERR! errno 1
npm ERR! cli-demo@0.0.1 acrolinx: `node scripts/test-result.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cli-demo@0.0.1 acrolinx script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2019-02-06T18_40_34_394Z-debug.log