-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Handle additional yarn
workspace definition formats
#463
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 |
---|---|---|
|
@@ -194,10 +194,13 @@ module.exports = CoreObject.extend({ | |
let restoreTasks = [ | ||
copy(path.join(this.cwd, this.packageJSONBackupFileName), | ||
path.join(this.cwd, this.packageJSON)), | ||
copy(path.join(this.cwd, this.nodeModulesBackupLocation), | ||
path.join(this.cwd, this.nodeModules), { clobber: true }), | ||
]; | ||
|
||
if (fs.existsSync(path.join(this.cwd, this.nodeModulesBackupLocation))) { | ||
restoreTasks.push(copy(path.join(this.cwd, this.nodeModulesBackupLocation), | ||
path.join(this.cwd, this.nodeModules), { clobber: true })); | ||
} | ||
|
||
if (fs.existsSync(path.join(this.cwd, this.yarnLockBackupFileName))) { | ||
restoreTasks.push(copy(path.join(this.cwd, this.yarnLockBackupFileName), | ||
path.join(this.cwd, this.yarnLock))); | ||
|
@@ -222,9 +225,12 @@ module.exports = CoreObject.extend({ | |
|
||
let backupTasks = [ | ||
copy(path.join(this.cwd, this.packageJSON), | ||
path.join(this.cwd, this.packageJSONBackupFileName)), | ||
copy(path.join(this.cwd, this.nodeModules), | ||
path.join(this.cwd, this.nodeModulesBackupLocation), { clobber: true })]; | ||
path.join(this.cwd, this.packageJSONBackupFileName))]; | ||
|
||
if (fs.existsSync(path.join(this.cwd, this.nodeModules))) { | ||
backupTasks.push(copy(path.join(this.cwd, this.nodeModules), | ||
path.join(this.cwd, this.nodeModulesBackupLocation), { clobber: true })); | ||
} | ||
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. Similar to above, but when backing up packages |
||
|
||
if (fs.existsSync(path.join(this.cwd, this.yarnLock))) { | ||
backupTasks.push(copy(path.join(this.cwd, this.yarnLock), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,11 @@ module.exports = CoreObject.extend({ | |
} | ||
|
||
let packageJSON = JSON.parse(fs.readFileSync(this.packageJSON)); | ||
let workspaceGlobs = packageJSON.workspaces; | ||
let workspaceGlobs = packageJSON.workspaces | ||
|
||
if (workspaceGlobs && workspaceGlobs.packages) { | ||
workspaceGlobs = workspaceGlobs.packages | ||
} | ||
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. Can you tweak this to be specific about what we expect? I'm thinking of something like: let workspaceGlobs = Array.isArray(packageJSON.workspaces) ? packageJSON.workspaces : packageJSON.workspaces.packages; 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. Sure! Ended up with if (Array.isArray(packageJSON.workspaces)) {
workspaceGlobs = packageJSON.workspaces
}
if (packageJSON.workspaces && Array.isArray(packageJSON.workspaces.packages)) {
workspaceGlobs = packageJSON.workspaces.packages
} so it's specific about each case |
||
|
||
if (!workspaceGlobs || !workspaceGlobs.length) { | ||
throw new Error('you must define the `workspaces` property in package.json with at least one workspace to use workspaces with ember-try'); | ||
|
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.
Yarn workspaces can hoist packages in such a way that a
node_modules
folder may never be created. This checks the existence of the directory before trying to restore it