Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* Performance cache for information about packages (projects/addons/"apps"/modules)
* under an initial root directory and resolving addon/dependency links to other packages.
*/
const fs = require('fs-extra');
const path = require('path');
const ErrorList = require('./error-list');
const Errors = require('./errors');
const PackageInfo = require('./package-info');
const NodeModulesList = require('./node-modules-list');
const logger = require('heimdalljs-logger')('ember-cli:package-info-cache');
const resolvePackagePath = require('resolve-package-path');
const getRealFilePath = resolvePackagePath.getRealFilePath;
const getRealDirectoryPath = resolvePackagePath.getRealDirectoryPath;
const _resetCache = resolvePackagePath._resetCache;
const PACKAGE_JSON = 'package.json';
/**
* Class that stores entries that are either PackageInfo or NodeModulesList objects.
* The entries are stored in a map keyed by real directory path.
*
* @public
* @class PackageInfoCache
*/
class PackageInfoCache {
constructor(ui) {
this.ui = ui; // a console-ui instance
this._clear();
}
/*
* Performance cache for information about packages (projects/addons/"apps"/modules)
* under an initial root directory and resolving addon/dependency links to other packages.
*/
const fs = require('fs-extra');
const path = require('path');
const ErrorList = require('./error-list');
const Errors = require('./errors');
const PackageInfo = require('./package-info');
const NodeModulesList = require('./node-modules-list');
const logger = require('heimdalljs-logger')('ember-cli:package-info-cache');
const resolvePackagePath = require('resolve-package-path');
const getRealFilePath = resolvePackagePath.getRealFilePath;
const getRealDirectoryPath = resolvePackagePath.getRealDirectoryPath;
const _resetCache = resolvePackagePath._resetCache;
const PACKAGE_JSON = 'package.json';
/**
* Class that stores entries that are either PackageInfo or NodeModulesList objects.
* The entries are stored in a map keyed by real directory path.
*
* @public
* @class PackageInfoCache
*/
class PackageInfoCache {
constructor(ui) {
this.ui = ui; // a console-ui instance
this._clear();
}
/*
* Performance cache for information about packages (projects/addons/"apps"/modules)
* under an initial root directory and resolving addon/dependency links to other packages.
*/
const fs = require('fs-extra');
const path = require('path');
const ErrorList = require('./error-list');
const Errors = require('./errors');
const PackageInfo = require('./package-info');
const NodeModulesList = require('./node-modules-list');
const logger = require('heimdalljs-logger')('ember-cli:package-info-cache');
const resolvePackagePath = require('resolve-package-path');
const getRealFilePath = resolvePackagePath.getRealFilePath;
const getRealDirectoryPath = resolvePackagePath.getRealDirectoryPath;
const _resetCache = resolvePackagePath._resetCache;
const PACKAGE_JSON = 'package.json';
/**
* Class that stores entries that are either PackageInfo or NodeModulesList objects.
* The entries are stored in a map keyed by real directory path.
*
* @public
* @class PackageInfoCache
*/
class PackageInfoCache {
constructor(ui) {
this.ui = ui; // a console-ui instance
this._clear();
return getOrCreate(cache, packageName, () => {
let root = dirname(resolvePackagePath(packageName, this.basedir(fromPackage)));
return this.getAddon(root);
});
}
private get emberCLILocation() {
const emberCLIPackage = resolvePackagePath('ember-cli', this.root);
if (emberCLIPackage === null) {
throw new Error(`Embroider: cannot resolve ember-cli's package.json`);
}
return dirname(emberCLIPackage);
}