Skip to content

Commit

Permalink
Fix for building registry deps (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennor authored and mkucharz committed Mar 20, 2018
1 parent 000fcc9 commit a517577
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
14 changes: 9 additions & 5 deletions packages/cli/src/commands/socket-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export default class SocketAdd {
if (cmd.socket) {
// Socket dependency
this.socket = await this.Socket.get(cmd.socket)
return this.socket.addDependency(socketFromRegistry)
await this.socket.addDependency(socketFromRegistry)
} else {
// Project dependency
await this.Socket.add(socketFromRegistry)
}

// Project dependency
await this.Socket.add(socketFromRegistry)

const status = format.grey('socket added:')
const name = format.cyan(this.socketFromRegistry.name)
const version = format.dim(`(${this.socketFromRegistry.version})`)
Expand Down Expand Up @@ -61,7 +61,11 @@ export default class SocketAdd {
}
} else {
echo()
echo(`${format.red(err)}\n`)
if(err.message) {
echo(`${format.red(err.message)}\n`)
} else {
echo(`${format.red(err)}\n`)
}
echo()
}
}
Expand Down
16 changes: 11 additions & 5 deletions packages/cli/src/utils/sockets/sockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,10 @@ class Socket {
debug(`Getting Socket: ${socketName}`)
const socket = Socket.getLocal(socketName)
const loadedSocket = await socket.loadRemote()
await loadedSocket.getDepsRegistrySockets()

if (!socket.existLocally) {
await socket.loadFromRegistry()
}
await loadedSocket.getDepsRegistrySockets()
return socket
}

Expand Down Expand Up @@ -564,7 +563,7 @@ class Socket {

getSocketNodeModulesChecksum () {
debug('getSocketNodeModulesChecksum')
return hashdirectory.sync(path.join(this.socketPath, '.dist', 'node_modules'))
return hashdirectory.sync(path.join(this.getSocketPath(), '.dist', 'node_modules'))
}

getSocketConfigFile () {
Expand Down Expand Up @@ -1021,9 +1020,16 @@ class Socket {
await new Promise((resolve, reject) => {
fs.createReadStream(fileName)
.pipe(unzip.Extract({ path: this.getSocketPath() }))
.on('close', () => {
.on('close', async () => {
debug('Unzip finished')
resolve()

// Build registry socket.
try {
await this.build()
} catch(e) {
return reject(e)
}
return resolve()
})
})
}
Expand Down

0 comments on commit a517577

Please sign in to comment.