-
-
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 2 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,30 @@ export class TnsModulesCopy { | |
|
||
// remove platform-specific files (processed separately by plugin services) | ||
shelljs.rm("-rf", path.join(targetPackageDir, "platforms")); | ||
|
||
this.removeNotProductionDependencies(dependency, targetPackageDir); | ||
} | ||
} | ||
|
||
private removeNotProductionDependencies(dependency: IDependencyData, targetPackageDir: string): void { | ||
let packageJsonFilePath = path.join(dependency.directory, "package.json"); | ||
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(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); | ||
|
||
for (let i = 0; i < dependencies.length; i++) { | ||
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. The let dependencies = this.$fs.readDirectory(dependenciesFolder);
dependencies.filter(dir => !!!productionDependencies || !productionDependencies.hasOwnProperty(dir))
.map(dir => shelljs.rm("-rf", path.join(dependenciesFolder, dir)); for consistency with the rest of the code base. |
||
let dir = dependencies[i]; | ||
if (productionDependencies == null || !productionDependencies.hasOwnProperty(dir)) { | ||
shelljs.rm("-rf", path.join(dependenciesFolder, dir)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
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.
removeNonProductionDependencies? (typo?)