Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(cli): empty zip
  • Loading branch information
mkucharz committed Mar 9, 2018
commit 299615819c288af1e0cea43a95974dcd3b755e26
24 changes: 22 additions & 2 deletions packages/cli/src/utils/sockets/sockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ class Socket {
return path.join(session.getDistPath(), `${this.name}.env.zip`)
}

isEmptyEnv () {
return fs.existsSync(this.getSocketEnvZip())
}

getSocketNodeModulesChecksum () {
debug('getSocketNodeModulesChecksum')
return hashdirectory.sync(path.join(this.socketPath, '.dist', 'node_modules'))
Expand Down Expand Up @@ -797,6 +801,12 @@ class Socket {
mkdirp.sync(envFolder)
}

if (this.isEmptyEnv()) {
fs.unlinkSync(this.getSocketEnvZip())
}

let filesInZip = 0

archive.pipe(output)
archive.on('error', reject)

Expand All @@ -808,9 +818,14 @@ class Socket {

files.forEach(file => {
archive.file(path.join(envFolder, file), {name: path.join('node_modules', file)})
filesInZip += 1
})

archive.finalize()
if (filesInZip) {
archive.finalize()
resolve()
}

output.on('close', () => {
resolve()
})
Expand Down Expand Up @@ -910,7 +925,12 @@ class Socket {
const form = new FormData()

form.append('name', this.name)
form.append('environment', this.name)

if (this.isEmptyEnv()) {
form.append('environment', null)
} else {
form.append('environment', this.name)
}

if (config) {
form.append('config', JSON.stringify(config))
Expand Down