mirror of
https://github.com/nodejs/node.git
synced 2025-05-19 20:06:58 +00:00

If the package.json file does not have a "main" entry, return undefined rather than an empty string. This is to make more consistent behavior. For example, when package.json is a directory, "main" is undefined rather than an empty string. PR-URL: https://github.com/nodejs/node/pull/18593 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
16 lines
608 B
JavaScript
16 lines
608 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const { internalModuleReadJSON } = process.binding('fs');
|
|
const { readFileSync } = require('fs');
|
|
const { strictEqual } = require('assert');
|
|
|
|
strictEqual(internalModuleReadJSON('nosuchfile'), undefined);
|
|
strictEqual(internalModuleReadJSON(fixtures.path('empty.txt')), undefined);
|
|
strictEqual(internalModuleReadJSON(fixtures.path('empty-with-bom.txt')),
|
|
undefined);
|
|
{
|
|
const filename = fixtures.path('require-bin/package.json');
|
|
strictEqual(internalModuleReadJSON(filename), readFileSync(filename, 'utf8'));
|
|
}
|