add callback to onDidReplaceAtomProject and add tests

This commit is contained in:
Philip Weiss
2018-02-26 14:38:50 -08:00
parent 607b3ffe52
commit 547b067f3e
4 changed files with 62 additions and 7 deletions

View File

@@ -1021,7 +1021,7 @@ class Config {
this.resetUserScopedSettings(pathScopedSettings, {source: PROJECT})
}
removeProjectSettings () {
clearProjectSettings () {
this.resetProjectSettings({}, {removeProject: true})
}

View File

@@ -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 => {