Skip to content

Commit

Permalink
bring it to manual config as well
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-yx committed Apr 6, 2019
1 parent 4c2d2d2 commit 177da2f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/utils/init/config-manual.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const inquirer = require('inquirer')
const { makeNetlifyTOMLtemplate } = require('./netlify-toml-template')

module.exports = configManual
async function configManual(ctx, site, repo) {
Expand Down Expand Up @@ -38,6 +39,27 @@ async function configManual(ctx, site, repo) {
default: '.'
}
])

const fs = require('fs')
const path = require('path')
const tomlpath = path.join(ctx.netlify.site.root, 'netlify.toml')
const tomlDoesNotExist = !fs.existsSync(tomlpath)
if (tomlDoesNotExist && (!ctx.netlify.config || Object.keys(ctx.netlify.config).length === 0)) {
const { makeNetlifyTOML } = await inquirer.prompt([
{
type: 'confirm',
name: 'makeNetlifyTOML',
message: 'No netlify.toml detected. Would you like to create one with these build settings?',
default: true
}
])
if (makeNetlifyTOML && ctx.netlify.site && ctx.netlify.site.root) {
fs.writeFileSync(tomlpath, makeNetlifyTOMLtemplate({ command: buildCmd, publish: buildDir }))
} else {
throw new Error('NetlifyCLIError: expected there to be a Netlify site root, please investigate', ctx.netlify.site)
}
}

repo.dir = buildDir

if (!repo.repo_path) {
Expand Down

0 comments on commit 177da2f

Please sign in to comment.