Sha256: 81561b31e3488c0d82655a6e8a80f3c6ca490ccea5274eaf5b2b2ddb4fe9bfcb

Contents?: true

Size: 1.59 KB

Versions: 23

Compression:

Stored size: 1.59 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.findPackageData = findPackageData;
function _path() {
  const data = require("path");
  _path = function () {
    return data;
  };
  return data;
}
var _utils = require("./utils.js");
var _configError = require("../../errors/config-error.js");
const PACKAGE_FILENAME = "package.json";
const readConfigPackage = (0, _utils.makeStaticFileCache)((filepath, content) => {
  let options;
  try {
    options = JSON.parse(content);
  } catch (err) {
    throw new _configError.default(`Error while parsing JSON - ${err.message}`, filepath);
  }
  if (!options) throw new Error(`${filepath}: No config detected`);
  if (typeof options !== "object") {
    throw new _configError.default(`Config returned typeof ${typeof options}`, filepath);
  }
  if (Array.isArray(options)) {
    throw new _configError.default(`Expected config object but found array`, filepath);
  }
  return {
    filepath,
    dirname: _path().dirname(filepath),
    options
  };
});
function* findPackageData(filepath) {
  let pkg = null;
  const directories = [];
  let isPackage = true;
  let dirname = _path().dirname(filepath);
  while (!pkg && _path().basename(dirname) !== "node_modules") {
    directories.push(dirname);
    pkg = yield* readConfigPackage(_path().join(dirname, PACKAGE_FILENAME));
    const nextLoc = _path().dirname(dirname);
    if (dirname === nextLoc) {
      isPackage = false;
      break;
    }
    dirname = nextLoc;
  }
  return {
    filepath,
    directories,
    pkg,
    isPackage
  };
}
0 && 0;

//# sourceMappingURL=package.js.map

Version data entries

23 entries across 16 versions & 3 rubygems

Version Path
trusty-cms-6.3.1 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.51 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.51 node_modules/jscodeshift/node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.50 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.50 node_modules/jscodeshift/node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.49 node_modules/jscodeshift/node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.49 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.48 node_modules/jscodeshift/node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.48 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.47 node_modules/jscodeshift/node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.47 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.46 node_modules/jscodeshift/node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.46 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.45 node_modules/jscodeshift/node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.45 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.44 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.43 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.42 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.41 node_modules/@babel/core/lib/config/files/package.js
immosquare-cleaner-0.1.40 node_modules/@babel/core/lib/config/files/package.js