mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
add callback to onDidReplaceAtomProject and add tests
This commit is contained in:
@@ -1021,7 +1021,7 @@ class Config {
|
||||
this.resetUserScopedSettings(pathScopedSettings, {source: PROJECT})
|
||||
}
|
||||
|
||||
removeProjectSettings () {
|
||||
clearProjectSettings () {
|
||||
this.resetProjectSettings({}, {removeProject: true})
|
||||
}
|
||||
|
||||
|
||||
@@ -84,21 +84,21 @@ class Project extends Model {
|
||||
atom.config.resetProjectSettings(newSettings.config)
|
||||
this.projectFilePath = newSettings.originPath
|
||||
this.setPaths(newSettings.paths)
|
||||
this.emitter.emit('replaced-atom-project', newSettings)
|
||||
this.emitter.emit('replace-atom-project', newSettings)
|
||||
}
|
||||
|
||||
onDidReplaceAtomProject (callback) {
|
||||
return this.emitter.on('replaced-atom-project', callback)
|
||||
return this.emitter.on('replace-atom-project', callback)
|
||||
}
|
||||
|
||||
clearAtomProject () {
|
||||
atom.config.clearProjectSettings()
|
||||
this.setPaths([])
|
||||
this.projectFilePath = null
|
||||
this.emitter.emit('replaced-atom-project', {})
|
||||
this.emitter.emit('replace-atom-project', {})
|
||||
}
|
||||
|
||||
getProjectFilePath () {
|
||||
getAtomProjectFilePath () {
|
||||
return this.projectFilePath
|
||||
}
|
||||
|
||||
@@ -347,14 +347,18 @@ class Project extends Model {
|
||||
// * `exact` If `true`, only add `projectPath` if it names an existing directory. If `false`, if `projectPath` is a
|
||||
// a file or does not exist, its parent directory will be added instead.
|
||||
addPath (projectPath, options = {}) {
|
||||
const directory = this.getDirectoryForProjectPath(projectPath)
|
||||
|
||||
const directory = this.getDirectoryForProjectPath(projectPath)
|
||||
if (projectPath === "/Users/foo/baz") {
|
||||
console.log("ree", directory)
|
||||
}
|
||||
let ok = true
|
||||
if (options.exact === true) {
|
||||
ok = (directory.getPath() === projectPath)
|
||||
}
|
||||
ok = ok && directory.existsSync()
|
||||
|
||||
|
||||
if (!ok) {
|
||||
if (options.mustExist === true) {
|
||||
const err = new Error(`Project directory ${directory} does not exist`)
|
||||
@@ -369,6 +373,7 @@ class Project extends Model {
|
||||
if (existingDirectory.getPath() === directory.getPath()) { return }
|
||||
}
|
||||
|
||||
|
||||
this.rootDirectories.push(directory)
|
||||
|
||||
const didChangeCallback = events => {
|
||||
|
||||
Reference in New Issue
Block a user