Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: Add channel and version to config ctor options (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbergman authored and jdx committed Oct 4, 2018
1 parent d15faab commit 65ce583
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export type ArchTypes = 'arm' | 'arm64' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' |
export interface Options extends Plugin.Options {
devPlugins?: boolean
userPlugins?: boolean
channel?: string
version?: string
}

const debug = Debug()
Expand Down Expand Up @@ -174,8 +176,8 @@ export class Config implements IConfig {
this.root = plugin.root
this.pjson = plugin.pjson
this.name = this.pjson.name
this.version = this.pjson.version || '0.0.0'
this.channel = channelFromVersion(this.version)
this.version = this.options.version || this.pjson.version || '0.0.0'
this.channel = this.options.channel || channelFromVersion(this.version)
this.valid = plugin.valid

this.arch = (os.arch() === 'ia32' ? 'x86' : os.arch() as any)
Expand Down
11 changes: 10 additions & 1 deletion test/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as os from 'os'
import * as path from 'path'

import {IConfig, load, PJSON} from '../src'
import {Config, IConfig, load, PJSON} from '../src'
import * as util from '../src/util'

import {expect, fancy} from './test'
Expand Down Expand Up @@ -106,6 +106,15 @@ describe('Config', () => {
.hasS3Key('versioned', 'channels/beta/oclif-cli-v2.0.0-beta/oclif-cli-v2.0.0-beta-darwin-x64.tar.gz', {...beta, ...target})
})

describe('options', () => {
it('should set the channel and version', async () => {
let config = new Config({root: process.cwd(), channel: 'test-channel', version: '0.1.2-test'})
await config.load()
expect(config).to.have.property('channel', 'test-channel')
expect(config).to.have.property('version', '0.1.2-test')
})
})

testConfig()
.it('has s3Url', config => {
const orig = config.pjson.oclif.update.s3.host
Expand Down

0 comments on commit 65ce583

Please sign in to comment.