-
-
Notifications
You must be signed in to change notification settings - Fork 197
Doesn't handle the dependencies of devDependencies #602
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,41 +30,43 @@ export class DestCopy implements IBroccoliPlugin { | |
|
||
public rebuildChangedDirectories(changedDirectories: string[], platform: string): void { | ||
_.each(changedDirectories, changedDirectoryAbsolutePath => { | ||
let pathToPackageJson = path.join(changedDirectoryAbsolutePath, "package.json"); | ||
let packageJsonFiles = fs.existsSync(pathToPackageJson) ? [pathToPackageJson] : []; | ||
let nodeModulesFolderPath = path.join(changedDirectoryAbsolutePath, "node_modules"); | ||
packageJsonFiles = packageJsonFiles.concat(this.enumeratePackageJsonFilesSync(nodeModulesFolderPath)); | ||
|
||
_.each(packageJsonFiles, packageJsonFilePath => { | ||
let fileContent = require(packageJsonFilePath); | ||
let isPlugin = fileContent.nativescript; | ||
|
||
if(!this.devDependencies[fileContent.name]) { // Don't flatten dev dependencies | ||
|
||
let currentDependency = { | ||
name: fileContent.name, | ||
version: fileContent.version, | ||
directory: path.dirname(packageJsonFilePath), | ||
isPlugin: isPlugin | ||
}; | ||
if(!this.devDependencies[path.basename(changedDirectoryAbsolutePath)]) { | ||
let pathToPackageJson = path.join(changedDirectoryAbsolutePath, constants.PACKAGE_JSON_FILE_NAME); | ||
let packageJsonFiles = fs.existsSync(pathToPackageJson) ? [pathToPackageJson] : []; | ||
let nodeModulesFolderPath = path.join(changedDirectoryAbsolutePath, constants.NODE_MODULES_FOLDER_NAME); | ||
packageJsonFiles = packageJsonFiles.concat(this.enumeratePackageJsonFilesSync(nodeModulesFolderPath)); | ||
|
||
let addedDependency = this.dependencies[currentDependency.name]; | ||
if (addedDependency) { | ||
if (semver.gt(currentDependency.version, addedDependency.version)) { | ||
let currentDependencyMajorVersion = semver.major(currentDependency.version); | ||
let addedDependencyMajorVersion = semver.major(addedDependency.version); | ||
|
||
let message = `The depedency located at ${addedDependency.directory} with version ${addedDependency.version} will be replaced with dependency located at ${currentDependency.directory} with version ${currentDependency.version}`; | ||
let logger = $injector.resolve("$logger"); | ||
currentDependencyMajorVersion === addedDependencyMajorVersion ? logger.out(message) : logger.warn(message); | ||
_.each(packageJsonFiles, packageJsonFilePath => { | ||
let fileContent = require(packageJsonFilePath); | ||
|
||
if(!this.devDependencies[fileContent.name]) { // Don't flatten dev dependencies | ||
let isPlugin = fileContent.nativescript; | ||
|
||
let currentDependency = { | ||
name: fileContent.name, | ||
version: fileContent.version, | ||
directory: path.dirname(packageJsonFilePath), | ||
isPlugin: isPlugin | ||
}; | ||
|
||
let addedDependency = this.dependencies[currentDependency.name]; | ||
if (addedDependency) { | ||
if (semver.gt(currentDependency.version, addedDependency.version)) { | ||
let currentDependencyMajorVersion = semver.major(currentDependency.version); | ||
let addedDependencyMajorVersion = semver.major(addedDependency.version); | ||
|
||
let message = `The depedency located at ${addedDependency.directory} with version ${addedDependency.version} will be replaced with dependency located at ${currentDependency.directory} with version ${currentDependency.version}`; | ||
let logger = $injector.resolve("$logger"); | ||
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 resolve this once outside of the |
||
currentDependencyMajorVersion === addedDependencyMajorVersion ? logger.out(message) : logger.warn(message); | ||
|
||
this.dependencies[currentDependency.name] = currentDependency; | ||
} | ||
} else { | ||
this.dependencies[currentDependency.name] = currentDependency; | ||
} | ||
} else { | ||
this.dependencies[currentDependency.name] = currentDependency; | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
_.each(this.dependencies, dependency => { | ||
|
@@ -98,12 +100,12 @@ export class DestCopy implements IBroccoliPlugin { | |
if(fs.existsSync(nodeModulesDirectoryPath)) { | ||
let contents = fs.readdirSync(nodeModulesDirectoryPath); | ||
for (let i = 0; i < contents.length; ++i) { | ||
let packageJsonFilePath = path.join(nodeModulesDirectoryPath, contents[i], "package.json"); | ||
let packageJsonFilePath = path.join(nodeModulesDirectoryPath, contents[i], constants.PACKAGE_JSON_FILE_NAME); | ||
if (fs.existsSync(packageJsonFilePath)) { | ||
foundFiles.push(packageJsonFilePath); | ||
} | ||
|
||
var directoryPath = path.join(nodeModulesDirectoryPath, contents[i], "node_modules"); | ||
var directoryPath = path.join(nodeModulesDirectoryPath, contents[i], constants.NODE_MODULES_FOLDER_NAME); | ||
if (fs.existsSync(directoryPath)) { | ||
this.enumeratePackageJsonFilesSync(directoryPath, foundFiles); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I would personally use
filter
here. This will make the code more readable and remove the code nesting with one level.