Skip to content

Commit

Permalink
fix(server): use correct store location when running in background
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Jan 28, 2018
1 parent 46d38a6 commit 1dc1f85
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/createStoreController.ts
Expand Up @@ -49,7 +49,7 @@ export default async function (
if (err.code !== 'ENOENT') throw err
}
if (opts.useStoreServer) {
runServerInBackground()
runServerInBackground(store)
const operation = retry.operation()

return new Promise<{
Expand Down
4 changes: 3 additions & 1 deletion src/runServerInBackground.ts
Expand Up @@ -3,4 +3,6 @@ import path = require('path')

const pnpm = path.join(__dirname, 'bin', 'pnpm.js')

export default () => diable.daemonize(pnpm, ['server', 'start'], {stdio: 'inherit'})
export default (storePath: string) => {
return diable.daemonize(pnpm, ['server', 'start', '--store', storePath], {stdio: 'inherit'})
}
27 changes: 27 additions & 0 deletions test/server.ts
Expand Up @@ -189,6 +189,33 @@ test('installation using store server started in the background', async (t: tape
t.notOk(await pathExists(serverJsonPath), 'server.json removed')
})

test('store server started in the background should use store location wanted by install', async (t: tape.Test) => {
const project = prepare(t)

await execPnpm('install', 'is-positive@1.0.0', '--use-store-server', '--store', '../store2')

const serverJsonPath = path.resolve('..', 'store2', '2', 'server.json')
const serverJson = await retryLoadJsonFile(serverJsonPath)
t.ok(serverJson)
t.ok(serverJson.connectionOptions)

t.ok(project.requireModule('is-positive'))

await execPnpm('uninstall', 'is-positive', '--store', '../store2')

await execPnpm('store', 'prune', '--store', '../store2')

// we don't actually know when the server will prune the store
// lets' just wait a bit before checking
await delay(1000)

await project.storeHasNot('is-positive', '1.0.0')

await execPnpm('server', 'stop', '--store', '../store2')

t.notOk(await pathExists(serverJsonPath), 'server.json removed')
})

test('installation without store server running in the background', async (t: tape.Test) => {
const project = prepare(t)

Expand Down

0 comments on commit 1dc1f85

Please sign in to comment.