server: don’t scaffold integration or fixtures when value has been set by user

This commit is contained in:
Chris Breiding
2017-07-07 16:30:32 -04:00
parent 036cc22070
commit 9425054fa0
2 changed files with 39 additions and 24 deletions
+11 -2
View File
@@ -71,18 +71,27 @@ module.exports = {
isNewProject
integration: (folder, config) ->
log "integration in folder #{folder}"
log "integration folder #{folder}"
## skip if user has explicitly set integrationFolder
return Promise.resolve() if not isDefault(config, "integrationFolder")
@verifyScaffolding folder, =>
log "copying examples into #{folder}"
@_copy(INTEGRATION_EXAMPLE_SPEC, folder, config)
fixture: (folder, config) ->
log "fixture folder #{folder}"
## skip if user has explicitly set fixturesFolder
return Promise.resolve() if not isDefault(config, "fixturesFolder")
@verifyScaffolding folder, =>
log "fixture needs to copy example.json"
@_copy("example.json", folder, config)
support: (folder, config) ->
log "support folder #{folder} support file #{config.supportFile}"
log "support folder #{folder}, support file #{config.supportFile}"
## skip if user has explicitly set supportFile
return Promise.resolve() if not isDefault(config, "supportFile")
+28 -22
View File
@@ -89,16 +89,13 @@ describe "lib/scaffold", ->
context ".integration", ->
beforeEach ->
todosPath = Fixtures.projectPath("todos")
pristinePath = Fixtures.projectPath("pristine")
config.get(todosPath).then (@cfg) =>
config.get(pristinePath).then (@cfg) =>
{@integrationFolder} = @cfg
it "creates both integrationFolder and example_spec.js when integrationFolder does not exist", ->
## todos has an integration folder so let's first nuke it and then scaffold
fs.removeAsync(@integrationFolder)
.then =>
scaffold.integration(@integrationFolder, @cfg)
scaffold.integration(@integrationFolder, @cfg)
.then =>
Promise.all([
fs.statAsync(@integrationFolder + "/example_spec.js").get("size")
@@ -106,12 +103,18 @@ describe "lib/scaffold", ->
]).spread (size1, size2) ->
expect(size1).to.eq(size2)
it "does not create example_spec.js if integrationFolder already exists", ->
## first remove it
fs.removeAsync(@integrationFolder)
it "does not create any files if integrationFolder is not default", ->
@cfg.resolved.integrationFolder.from = "config"
scaffold.integration(@integrationFolder, @cfg)
.then =>
## create the integrationFolder ourselves manually
fs.ensureDirAsync(@integrationFolder)
glob("**/*", {cwd: @integrationFolder})
.then (files) ->
expect(files.length).to.eq(0)
it "does not create example_spec.js if integrationFolder already exists", ->
## create the integrationFolder ourselves manually
fs.ensureDirAsync(@integrationFolder)
.then =>
## now scaffold
scaffold.integration(@integrationFolder, @cfg)
@@ -272,16 +275,13 @@ describe "lib/scaffold", ->
context ".fixture", ->
beforeEach ->
todosPath = Fixtures.projectPath("todos")
pristinePath = Fixtures.projectPath("pristine")
config.get(todosPath).then (@cfg) =>
config.get(pristinePath).then (@cfg) =>
{@fixturesFolder} = @cfg
it "creates both fixturesFolder and example.json when fixturesFolder does not exist", ->
## todos has a fixtures folder so let's first nuke it and then scaffold
fs.removeAsync(@fixturesFolder)
.then =>
scaffold.fixture(@fixturesFolder, @cfg)
scaffold.fixture(@fixturesFolder, @cfg)
.then =>
fs.readFileAsync(@fixturesFolder + "/example.json", "utf8")
.then (str) ->
@@ -293,12 +293,18 @@ describe "lib/scaffold", ->
}
"""
it "does not create example.json if fixturesFolder already exists", ->
## first remove it
fs.removeAsync(@fixturesFolder)
it "does not create any files if fixturesFolder is not default", ->
@cfg.resolved.fixturesFolder.from = "config"
scaffold.fixture(@fixturesFolder, @cfg)
.then =>
## create the fixturesFolder ourselves manually
fs.ensureDirAsync(@fixturesFolder)
glob("**/*", {cwd: @fixturesFolder})
.then (files) ->
expect(files.length).to.eq(0)
it "does not create example.json if fixturesFolder already exists", ->
## create the fixturesFolder ourselves manually
fs.ensureDirAsync(@fixturesFolder)
.then =>
## now scaffold
scaffold.fixture(@fixturesFolder, @cfg)