Internal: Read package.json's main and style directives.

 dirname  - String path to component directory.
 filename - String path to package.json.

 Returns nothing.
547694
def read_package_directives(dirname, filename)
      package = JSON.parse(File.read(filename), create_additions: false)

      case package['main']
      when String
        yield File.expand_path(package['main'], dirname)
      when nil
        yield File.expand_path('index.js', dirname)
      end

      yield File.expand_path(package['style'], dirname) if package['style']
    end
585122
function modulePath(module, node_modules) {
  var pkgFile = path.join(node_modules, module, 'package.json');
  if (!fs.existsSync(pkgFile)) {
    return null;
  }
  var data = fs.readFileSync(pkgFile, 'utf8');
  var pkg = JSON.parse(data);
  var fileName = pkg.main || 'index.js';
  var filePath = path.join(node_modules, module, fileName);
  return realRequirPath(filePath);
}
907633
def get_package_filename(filename, package_dir=None):
    ''''''
    if getattr(sys, 'frozen', False):
        package_dir = os.path.join(
            sys._MEIPASS,
            os.path.basename(os.path.dirname(__file__))
        )
    elif not package_dir:
        package_dir = os.path.dirname(__file__)

    return os.path.join(package_dir, filename)
293258
function loadInfo() {
    try {
      var data = fs.readFileSync(__rootdir + '/package.json', { encoding: 'utf8' });
      var tmp = JSON.parse(data);
      appPackage = {
        name: tmp.name || null,
        version: tmp.version || 1
      }
    } catch(e) {
      return; // nothing to do.
    }
  }
392990
function (config, component) {
    var componentConfigFile;

    ['bower.json', '.bower.json', 'component.json', 'package.json'].
    forEach(function (configFile) {

        configFile = path.join(config.get('bower-directory'), component, configFile);

        console.log(configFile);

        if (!_.isObject(componentConfigFile) && fs.existsSync(configFile)) {
            componentConfigFile = JSON.parse(fs.readFileSync(configFile));
        }
    });



    return componentConfigFile;
}
300304
function resolveBin (moduleName) {
  // Get the directory from the module's package.json path
  const directory = path.dirname(require.resolve(`${moduleName}/package.json`))

  // Get the relative bin path from the module's package.json bin key
  let bin = require(`${moduleName}/package.json`).bin

  // Sometimes the bin file isn't a string but an object
  // This extracts the first bin from that object
  if (typeof bin !== 'string') {
    bin = Object.values(bin)[0]
  }

  return path.join(directory, bin)
}
112196
function(dir) {

        // Load the package.json if it exists (and remove relative refs)
        var pkg;
        dir = Path.resolve(dir);
        try {
          pkg = JSON.parse(FS.readFileSync(dir + '/package.json', 'utf-8'));
        } catch (e) {
          // Report an error if the package.json has a parse problem.  This is
          // good during app development to show why we didn't discover the app.
          if (e.code !== "ENOENT") {
             console.error("Problem parsing " + dir + "/package.json");
          }
          return false;
        }

        // Is this a monitor-dashboard app?
        var isMonitorApp = pkg.dependencies && _.find(_.keys(pkg.dependencies), function(keyword){ return keyword === 'monitor-dashboard'; });
        if (!isMonitorApp) {
          return false;
        }

        // This is a monitor-dashboard app.
        return t.loadApp(dir, pkg);
      }
587900
function dtsBundler() {
  const packageDirectories = fs.readdirSync(D_TS_DIRECTORY);
  packageDirectories.forEach((packageDirectory) => {
    const packagePath = path.join(PACKAGES_DIRECTORY, packageDirectory);
    const name = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json'), 'utf8')).name;
    const main = path.join(D_TS_DIRECTORY, packageDirectory, './index.d.ts');
    const isAllInOne = packageDirectory === ALL_IN_ONE_PACKAGE;
    const destBasename = isAllInOne ? packageDirectory : `mdc.${toCamelCase(packageDirectory.replace(/^mdc-/, ''))}`;
    const destFilename = path.join(packagePath, 'dist', `${destBasename}.d.ts`);

    console.log(`Writing UMD declarations in ${destFilename.replace(process.cwd() + '/', '')}`);
    dts.bundle({
      name,
      main,
      out: destFilename,
    });
  });
}
400734
function getPresetName(file) {
  const packageJson = findUp.sync("package.json", { cwd: path.dirname(file) });

  if (packageJson) {
    return require(packageJson).name || file;
  }

  return file;
}
1127680
async function updatePackageJSON (version) {
  ['package.json'].forEach(async fileName => {
    const filePath = path.resolve(__dirname, '..', fileName)
    const file = require(filePath)
    file.version = version
    await writeFile(filePath, JSON.stringify(file, null, 2))
  })
}
627478
function getInfo(d) {
  var p = path.join(d, 'package.json')
  return exists(p) ? require(p) : false
}
710432
public boolean scanDir(String dirname) {
        Path base = Paths.get(dirname);
        int baseCount = base.getNameCount();
        finder.addDir(dirname);
        try (Stream<Path> paths = Files.walk(Paths.get(dirname))) {
            List<Path> classes =
                paths.filter(p -> p.getNameCount() > baseCount)
                     .filter(path -> path.toString().endsWith(".class"))
                     .filter(path -> !path.toString().endsWith("package-info.class"))
                     .filter(path -> !path.toString().endsWith("module-info.class"))
                     .collect(Collectors.toList());

            out.println(Messages.get("scan.head.dir", dirname));

            for (Path p : classes) {
                processClass(ClassFile.read(p));
            }
            return true;
        } catch (IOException | ConstantPoolException ex) {
            errorException(ex);
            return false;
        }
    }
201535
def json(directory)
      path = File.join(directory, 'elm-package.json')
      JSON.parse(File.read(path))
    rescue JSON::ParserError
      warn "Invalid JSON in file: #{path.bold}"
    rescue Errno::ENOENT
      warn "Could not find file: #{path.bold}"
    end
204860
function readPackageJSON () {
	var pkg = JSON.parse(require('fs').readFileSync('./package.json'));
	var dependencies = pkg.dependencies ? Object.keys(pkg.dependencies) : [];
	var peerDependencies = pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [];

	return {
		name: pkg.name,
		deps: dependencies.concat(peerDependencies),
		aliasify: pkg.aliasify
	};
}
195598
function checkPackageJson () {
        const pkg = requireFresh(path.join(project, 'package.json'));
        expect(pkg.name).toEqual(appId);
        expect(pkg.displayName).toEqual(appName);
        expect(pkg.version).toEqual(appVersion);
    }
405575
public void mkPackage(String pkgName, File dir) {
        try {
            File metaDir = new File(dir + "/.mdw");
            if (!metaDir.exists() && !metaDir.mkdirs())
                throw new IOException("Cannot create directory: " + metaDir.getAbsolutePath());
            File pkgFile = new File(metaDir + "/package.yaml");
            if (!pkgFile.exists()) {
                JSONObject pkgJson = new JSONObject();
                pkgJson.put("name", pkgName);
                pkgJson.put("version", "1.0.01");
                pkgJson.put("schemaVersion", "6.1");
                Files.write(Paths.get(pkgFile.getPath()), pkgJson.toString(2).getBytes());
            }
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
    }
856071
function(location) {
  var found = false;

  while(!found) {
    if (exists(location + '/package.json')) {
      found = location;
    } else if (location !== '/') {
      location = path.dirname(location);
    } else {
      return false;
    }
  }

  return location;
}