-
-
Notifications
You must be signed in to change notification settings - Fork 197
Remove non-production dependencies which break npm links #2880
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
Changes from 4 commits
b22ce56
dc78584
9199f22
b26a124
7ba63e1
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 |
---|---|---|
|
@@ -51,6 +51,25 @@ export class TnsModulesCopy { | |
|
||
// remove platform-specific files (processed separately by plugin services) | ||
shelljs.rm("-rf", path.join(targetPackageDir, "platforms")); | ||
|
||
this.removeNonProductionDependencies(dependency, targetPackageDir); | ||
} | ||
} | ||
|
||
private removeNonProductionDependencies(dependency: IDependencyData, targetPackageDir: string): void { | ||
let packageJsonFilePath = path.join(dependency.directory, "package.json"); | ||
if (!this.$fs.exists(packageJsonFilePath)) { | ||
return; | ||
} | ||
|
||
let packageJsonContent = this.$fs.readJson(packageJsonFilePath); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all the |
||
let productionDependencies = packageJsonContent.dependencies; | ||
|
||
let dependenciesFolder = path.join(targetPackageDir, "node_modules"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can use |
||
if (this.$fs.exists(dependenciesFolder)) { | ||
let dependencies = this.$fs.readDirectory(dependenciesFolder); | ||
dependencies.filter(dir => !!productionDependencies || !productionDependencies.hasOwnProperty(dir)) | ||
.map(dir => shelljs.rm("-rf", path.join(dependenciesFolder, dir))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a map is not required here, this is |
||
} | ||
} | ||
} | ||
|
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.
you can use
constants.PACKAGE_JSON_FILE_NAME
instad ofpackage.json