Skip to content

Commit

Permalink
fix addGitIgnoreToWWW after prepare and build
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben committed Jun 20, 2019
1 parent 0b6f5b4 commit 7391eb3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion defaults.js
Expand Up @@ -3,5 +3,6 @@ module.exports = {
id: 'com.vue.example.app',
appName: 'VueExampleAppName',
platforms: ['android', 'ios', 'browser', 'osx'],
routerMode: 'hash'
routerMode: 'hash',
gitIgnoreContent: '*\n*/\n!.gitignore'
}
2 changes: 1 addition & 1 deletion generator.js
Expand Up @@ -103,7 +103,7 @@ module.exports = (api, options) => {

const wwwIgnorePath = api.resolve(`${cordovaPath}/www/.gitignore`)
api.exitLog(`Creating file: ${wwwIgnorePath}`)
fs.writeFileSync(wwwIgnorePath, '*\n*/\n!.gitignore')
fs.writeFileSync(wwwIgnorePath, defaults.gitIgnoreContent)

// platforms
const srcCordovaPath = api.resolve(cordovaPath)
Expand Down
12 changes: 12 additions & 0 deletions index.js
Expand Up @@ -193,12 +193,21 @@ module.exports = (api, options) => {
args.dest = cordovaPath + '/www'
// build
await api.service.run('build', args)

// add www/.gitignore again (because build will delete it)
addGitIgnoreToWWW()

// cordova clean
await cordovaClean()
// cordova build --release (if you want a build debug build, use cordovaBuild(platform, false)
await cordovaBuild(platform)
}

const addGitIgnoreToWWW = () => {
const wwwIgnorePath = api.resolve(`${cordovaPath}/www/.gitignore`)
fs.writeFileSync(wwwIgnorePath, defaults.gitIgnoreContent)
}

const runPrepare = async (args) => {
// add cordova.js, define process.env.CORDOVA_PLATFORM
chainWebPack(null)
Expand All @@ -207,6 +216,9 @@ module.exports = (api, options) => {
// build
await api.service.run('build', args)

// add www/.gitignore again (because build will delete it)
addGitIgnoreToWWW()

// cordova prepare
await cordovaPrepare()
}
Expand Down

0 comments on commit 7391eb3

Please sign in to comment.