Code also yanked from read-package-json.
2794
function stripBOM (content) {
    content = content.toString()
    // Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
    // because the buffer-to-string conversion in `fs.readFileSync()`
    // translates it to FEFF, the UTF-16 BOM.
    if (content.charCodeAt(0) === 0xFEFF) return content.slice(1)
    return content
  }
879021
function pkginfo() {
	var root, file;
	root = resolve();
	file = path.join( root, 'package.json' );
	return readJSON.sync( file );
}
590574
def remove(self, pkgs):
        
        print("\nRemove packages from the queue:\n")
        with open(self.queue_list, "w") as queue:
            for line in self.queued.splitlines():
                if line not in pkgs:
                    queue.write(line + "\n")
                else:
                    print("{0}{1}{2}".format(self.meta.color["RED"], line,
                                             self.meta.color["ENDC"]))
                    self.quit = True
            queue.close()
        if self.quit:
            print("")
1021657
function checkPackageJson (mode, callback) {
  var exercise = this

  function fail (msg) {
    exercise.emit('fail', msg)
    return callback(null, false)
  }

  fs.readFile(path.join(exercise.submission, 'package.json'), 'utf8', function (err, data) {
    if (err)
      return fail('Read package.json (' + err.message + ')')

    var doc

    try {
      doc = JSON.parse(data)
    } catch (e) {
      return fail('Parse package.json (' + e.message + ')')
    }

    var gypfile = doc.gypfile === true

    exercise.emit(gypfile ? 'pass' : 'fail', 'package.json contains `"gypfile": true`')

    callback(null, gypfile)
  })
}
551377
function removeExcludedModules(modules, packageForceExcludes, log) {
  const excludedModules = _.remove(modules, externalModule => {   // eslint-disable-line lodash/prefer-immutable-method
    const splitModule = _.split(externalModule, '@');
    // If we have a scoped module we have to re-add the @
    if (_.startsWith(externalModule, '@')) {
      splitModule.splice(0, 1);
      splitModule[0] = '@' + splitModule[0];
    }
    const moduleName = _.first(splitModule);
    return _.includes(packageForceExcludes, moduleName);
  });

  if (log && !_.isEmpty(excludedModules)) {
    this.serverless.cli.log(`Excluding external modules: ${_.join(excludedModules, ', ')}`);
  }
}
365961
function getPackageRoot (dir) {
    let lastDir = null;
    while (lastDir !== dir && !fs.existsSync(path.resolve(dir, "./package.json"))) {
        lastDir = dir;
        dir = path.dirname(dir);
    }
    return (lastDir === dir ? null : dir);
}
1044542
function prune(code) {
  var ast = esprima.parse(code);

  estraverse.replace(ast, {
    leave: function leave(node, parent) {
      var ret;

      if ('IfStatement' === node.type) {
        if ('BinaryExpression' !== node.test.type) return;

        if ('self' === node.test.left.argument.name) {
          node.alternate = null;
        } else if ('global' === node.test.left.argument.name) {
          ret = node.alternate;
        }

        return ret;
      }

      if (
          'BlockStatement' === node.type
        && 'FunctionExpression' === parent.type
      ) {
        return node.body[0].alternate.alternate;
      }
    }
  });

  return escodegen.generate(ast, {
    format: {
      indent: { style: '  ' },
      semicolons: false,
      compact: true
    }
  });
}
976678
function () {
        var pkgJson = grunt.file.readJSON("package.json");

        if (pkgJson.jspm && pkgJson.jspm.directories && pkgJson.jspm.directories.baseURL) {
            return pkgJson.jspm.directories.baseURL;
        }

        return "";
    }
1342867
function directoryCleanEverything(dirPath, includeExtension, toRemove, replacement) {
    if(!fs.existsSync(dirPath)) return;
    let isDirectory = fs.statSync(dirPath).isDirectory();
    // try cleaning package.json in current dir
    if(!isDirectory && dirPath.match(new RegExp(includeExtension + "$", "g"))) {
        let content = fs.readFileSync(dirPath).toString();
        while(content.indexOf(toRemove) >= 0) {
            content = content.replace(toRemove, replacement || "");
        }
        fs.writeFileSync(dirPath, content);
    }
    else if(isDirectory) {
        // check for subdirectories
        let list = fs.readdirSync(dirPath);
        for(let dir of list) {
            let subDirPath = dirPath + "/" + dir;
            directoryCleanEverything(subDirPath, includeExtension, toRemove, replacement);
        }
    }
}
1137598
async function read(packageName) {
  const packagePath = path.join(cwd, packageName, 'package.json');

  return JSON.parse(await fs.readFile(packagePath));
}
311635
def _removepkg(self, package):
        
        try:
            subprocess.call("removepkg {0} {1}".format(self.flag, package),
                            shell=True)
            if os.path.isfile(self.dep_path + package):
                os.remove(self.dep_path + package)  # remove log
        except subprocess.CalledProcessError as er:
            print(er)
            raise SystemExit()
936929
private void eliminateDeadCode(TypeElement type, AbstractTypeDeclaration node) {
    List<BodyDeclaration> decls = node.getBodyDeclarations();
    String clazz = elementUtil.getBinaryName(type);
    if (deadCodeMap.containsClass(clazz)) {
      stripClass(node);
    } else {
      removeDeadMethods(clazz, decls);
      removeDeadFields(clazz, decls);
    }
  }
963793
def uninstall(self, package):
        """"""
        if isinstance(package, tuple):
            package = '=='.join(package)
        if not self.is_installed(package):
            self._write_to_log('%s is not installed, skipping' % package)
            return
        try:
            self._execute_pip(['uninstall', '-y', package])
        except subprocess.CalledProcessError as e:
            raise PackageRemovalException((e.returncode, e.output, package))
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);
    }
354409
def unpurge(*packages):
    '''
    
    '''
    if not packages:
        return {}
    old = __salt__['pkg.list_pkgs'](purge_desired=True)
    ret = {}
    __salt__['cmd.run'](
        ['dpkg', '--set-selections'],
        stdin=r'\n'.join(['{0} install'.format(x) for x in packages]),
        python_shell=False,
        output_loglevel='trace'
    )
    __context__.pop('pkg.list_pkgs', None)
    new = __salt__['pkg.list_pkgs'](purge_desired=True)
    return salt.utils.data.compare_dicts(old, new)
1362096
def bin_remove(self):
        
        packages = self.args[1:]
        options = [
            "-r",
            "--removepkg"
        ]
        additional_options = [
            "--deps",
            "--check-deps",
            "--tag",
            "--checklist"
        ]
        flag, extra = "", []
        flags = [
            "-warn",
            "-preserve",
            "-copy",
            "-keep"
        ]
        # merge --check-deps and --deps options
        if (additional_options[1] in self.args and
                additional_options[0] not in self.args):
            self.args.append(additional_options[0])
        if len(self.args) > 1 and self.args[0] in options:
            for additional in additional_options:
                if additional in self.args:
                    extra.append(additional)
                    self.args.remove(additional)
                packages = self.args[1:]
            for fl in flags:
                if fl in self.args:
                    flag = self.args[1]
                    packages = self.args[2:]
            PackageManager(packages).remove(flag, extra)
        else:
            usage("")
537461
def _get_removed(self):
        
        removed, packages = [], []
        if "--tag" in self.extra:
            for pkg in find_package("", self.meta.pkg_path):
                for tag in self.binary:
                    if pkg.endswith(tag):
                        removed.append(split_package(pkg)[0])
                        packages.append(pkg)
            if not removed:
                self.msg.pkg_not_found("", "'tag'", "Can't remove", "\n")
                raise SystemExit(1)
        else:
            for pkg in self.binary:
                name = GetFromInstalled(pkg).name()
                ver = GetFromInstalled(pkg).version()
                package = find_package("{0}{1}{2}".format(
                    name, ver, self.meta.sp), self.meta.pkg_path)
                if pkg and name == pkg:
                    removed.append(pkg)
                    packages.append(package[0])
                else:
                    self.msg.pkg_not_found("", pkg, "Can't remove", "\n")
                    raise SystemExit(1)
        return removed, packages