Skip to content

Commit

Permalink
refactor: simplify retrieval of 3-party scripts dependencies
Browse files Browse the repository at this point in the history
- keep them in their own module directories
- find their path with require.resolve()
  • Loading branch information
rdeltour committed Sep 28, 2017
1 parent e0e79f7 commit 69aeb44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"npm": ">=4",
"yarn": ">= 0.20"
},
"main": "src/index.js",
"main": "dist/index.js",
"bin": {
"ace": "dist/cli/cli.js"
},
Expand Down Expand Up @@ -79,9 +79,7 @@
"start": "node dist/cli/cli.js",
"clean": "rimraf dist && mkdir dist",
"prebuild": "yarn run clean -s",
"build": "yarn run build:js -s && yarn run build:axe -s && yarn run build:h5o -s",
"build:axe": "mkdir -p dist/ext/axe && cp node_modules/axe-core/axe.min.js dist/ext/axe/",
"build:h5o": "mkdir dist/ext/h5o && cp node_modules/h5o/dist/outliner.min.js dist/ext/h5o/",
"build": "yarn run build:js -s",
"build:js": "cp -R src/ dist",
"build:watch": "watch 'yarn run build' src",
"test": "echo add tests",
Expand Down
4 changes: 2 additions & 2 deletions src/checker/checker-nightmare.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const report = require('../report/report.js');
const axe2ace = require('../report/axe2ace.js');
const winston = require('winston');

const PATH_TO_AXE = path.join(__dirname, '../ext/axe/axe.min.js');
const PATH_TO_AXE = path.join(path.dirname(require.resolve('axe-core')), 'axe.min.js');
if (!fs.existsSync(PATH_TO_AXE)) {
winston.verbose(PATH_TO_AXE);
process.exit(1);
}

const PATH_TO_H5O = path.join(__dirname, '../ext/h5o/outliner.min.js');
const PATH_TO_H5O = path.join(path.dirname(require.resolve('h5o')), 'dist/outliner.min.js');
if (!fs.existsSync(PATH_TO_H5O)) {
winston.verbose(PATH_TO_H5O);
process.exit(1);
Expand Down

0 comments on commit 69aeb44

Please sign in to comment.