-
Notifications
You must be signed in to change notification settings - Fork 17
prefer addon.moduleName as telemetry if one exists, otherwise fallback to packageName #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,12 +18,32 @@ for (let packagePath of packagePaths) { | |
| let packageDir = path.dirname(path.resolve(cwd, packagePath)); | ||
|
|
||
| if (pkg.keywords && pkg.keywords.includes('ember-addon')) { | ||
| ADDON_PATHS[packageDir] = pkg.name; | ||
| // build addon instance | ||
| ADDON_PATHS[packageDir] = getAddonPackageName(packagePath); | ||
| } else if (isEmberCliProject(pkg)) { | ||
| APP_PATHS[packageDir] = pkg.name; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * takes a package path and returns the runtime name of the addon. | ||
| * | ||
| * @param {String} packagePath the path on disk (from current working directory) | ||
| * @returns {String} The runtime name of the addon | ||
| */ | ||
| function getAddonPackageName(packagePath) { | ||
| const indexPath = path.resolve(path.dirname(packagePath), 'index.js'); | ||
|
||
|
|
||
| if (fs.existsSync(indexPath)) { | ||
| const { name: packageName, moduleName } = require(indexPath); | ||
| // this is bad, fix later | ||
| return moduleName && typeof moduleName === 'function' ? moduleName() : packageName; | ||
|
||
| } | ||
|
|
||
| const { name: packageName } = require(packagePath); | ||
| return packageName; | ||
| } | ||
hmajoros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| function isEmberCliProject(pkg) { | ||
| return ( | ||
| pkg && | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
packageDirand notpackagePath?(If it is
packagePath, this function dies attempting torequire('package.json')on my team's addon, but if it ispackageDir, then the native-class codemod is able to transform classes. Our setup is a multi-app monorepo that also contains a shared ember addon with reused components and services.)