From 69aeb44a5c993bb2c2a2bc45b395166fb2741ef1 Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Sun, 24 Sep 2017 21:22:01 +0200 Subject: [PATCH] refactor: simplify retrieval of 3-party scripts dependencies - keep them in their own module directories - find their path with require.resolve() --- package.json | 6 ++---- src/checker/checker-nightmare.js | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 47f56e9b..a4ca8b58 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "npm": ">=4", "yarn": ">= 0.20" }, - "main": "src/index.js", + "main": "dist/index.js", "bin": { "ace": "dist/cli/cli.js" }, @@ -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", diff --git a/src/checker/checker-nightmare.js b/src/checker/checker-nightmare.js index 9ea8c1d6..82b2369c 100644 --- a/src/checker/checker-nightmare.js +++ b/src/checker/checker-nightmare.js @@ -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);