Permalink
Browse files

make tests rely on package.json "main" field

Close gh-1384
  • Loading branch information...
1 parent ea8d19d commit a28c6917292247c8eccf956ed6be0229c7f64421 @michaelficarra michaelficarra committed with ariya Nov 16, 2015
View
@@ -2,3 +2,4 @@ coverage
node_modules
test/dist
src/*.js
+dist/esprima.js
View
@@ -32,7 +32,7 @@ if (typeof require === 'function') {
try {
esprima = require('esprima');
} catch (e) {
- esprima = require('../dist/esprima');
+ esprima = require('../');
}
} else if (typeof load === 'function') {
try {
View
@@ -39,7 +39,7 @@ if (typeof esprima === 'undefined') {
try {
esprima = require('esprima');
} catch (e) {
- esprima = require('../dist/esprima');
+ esprima = require('../');
}
} else if (typeof load === 'function') {
try {
View
@@ -105,7 +105,7 @@ if (typeof require === 'undefined') {
log = print;
} else {
Benchmark = require('./3rdparty/benchmark');
- esprima = require('../dist/esprima');
+ esprima = require('../');
quick = process.argv[2] === 'quick' || process.argv[3] === 'quick';
readFile = function (filename) {
return require('fs').readFileSync(filename, 'utf-8');
@@ -25,7 +25,7 @@
'use strict';
var escomplex = require('escomplex-js'),
- content = require('fs').readFileSync('dist/esprima.js', 'utf-8'),
+ content = require('fs').readFileSync(require.resolve('../'), 'utf-8'),
opt = { logicalor: false, switchcase: false },
MAX = 22,
list = [], bad = [];
@@ -32,7 +32,7 @@ function findCanonicalVersion() {
var matcher, lines, version;
matcher = /exports\.version\s+=\s+\'([0-9\.\-a-zA-Z]+)\'/;
- lines = fs.readFileSync('dist/esprima.js', 'utf-8').split('\n');
+ lines = fs.readFileSync(require.resolve('../'), 'utf-8').split('\n');
lines.forEach(function (line) {
if (matcher.test(line)) {
version = matcher.exec(line)[1];
View
@@ -25,7 +25,7 @@
var child_process = require('child_process'),
fs = require('fs'),
temp = require('temp').track(),
- source = fs.realpathSync('dist/esprima.js');
+ source = fs.realpathSync(require.resolve('../'));
function execute(cmd) {
child_process.execSync(cmd, { stdio: 'inherit' });
@@ -22,7 +22,7 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-var esprima = require('../dist/esprima');
+var esprima = require('../');
function readEverythingJsProgram(type) {
return require('fs').readFileSync(require.resolve('everything.js/' + type), 'utf-8');
@@ -23,7 +23,7 @@
*/
var fs = require('fs'),
- esprima = require('../dist/esprima'),
+ esprima = require('../'),
N, fixture;
// Loops for parsing, useful for stress-testing/profiling.
View
@@ -24,7 +24,7 @@
'use strict';
-var esprima = require('../dist/esprima'),
+var esprima = require('../'),
evaluateTestCase = require('./utils/evaluate-testcase'),
createTestCases = require('./utils/create-testcases'),
errorToObject = require('./utils/error-to-object'),
@@ -27,7 +27,7 @@
(function (root, factory) {
if (typeof module === 'object' && module.exports) {
module.exports = factory(
- require('../../dist/esprima'),
+ require('../../'),
require('./error-to-object')
);
} else {
@@ -42,4 +42,4 @@ function fixupbundle(filename) {
fs.writeFileSync(filename, content, 'utf-8');
}
-fixupbundle('dist/esprima.js');
+fixupbundle(require.resolve('../'));

0 comments on commit a28c691

Please sign in to comment.