Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
feat: add --no-xz flag to pack
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Sep 1, 2018
1 parent b1fdd21 commit c0a1fbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/commands/pack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ This can be used to create oclif CLIs that use the system node or that come prel
static flags = {
root: flags.string({char: 'r', description: 'path to oclif CLI root', default: '.', required: true}),
targets: flags.string({char: 't', description: 'comma-separated targets to pack (e.g.: linux-arm,win32-x64)'}),
xz: flags.boolean({description: 'also build xz', allowNo: true}),
}

async run() {
const prevCwd = qq.cwd()
if (process.platform === 'win32') throw new Error('pack does not function on windows')
const {flags} = this.parse(Pack)
const targets = flags.targets !== undefined ? flags.targets.split(',') : undefined
const buildConfig = await Tarballs.buildConfig(flags.root, targets)
const buildConfig = await Tarballs.buildConfig(flags.root, {xz: flags.xz, targets})
await Tarballs.build(buildConfig)
qq.cd(prevCwd)
}
Expand Down
8 changes: 5 additions & 3 deletions src/tarballs/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as Config from '@oclif/config'
import * as path from 'path'
import * as qq from 'qqjs'

import {compact} from '../util'

export interface IConfig {
root: string
gitSha: string
Expand Down Expand Up @@ -44,7 +46,7 @@ async function Tmp(config: Config.IConfig) {
return tmp
}

export async function buildConfig(root: string, targets?: string[]): Promise<IConfig> {
export async function buildConfig(root: string, options: {xz?: boolean, targets?: string[]} = {}): Promise<IConfig> {
const config = await Config.load({root: path.resolve(root), devPlugins: false, userPlugins: false})
const channel = config.channel
root = config.root
Expand All @@ -61,7 +63,7 @@ export async function buildConfig(root: string, targets?: string[]): Promise<ICo
updateConfig,
version,
channel,
xz: !!updateConfig.s3.xz,
xz: typeof options.xz === 'boolean' ? options.xz : !!updateConfig.s3.xz,
dist: (...args: string[]) => path.join(config.root, 'dist', ...args),
s3Config: updateConfig.s3,
nodeVersion: updateConfig.node.version || process.versions.node,
Expand All @@ -70,7 +72,7 @@ export async function buildConfig(root: string, targets?: string[]): Promise<ICo
if (target && target.platform) return qq.join(base, [target.platform, target.arch].join('-'), config.s3Key('baseDir', target))
return qq.join(base, config.s3Key('baseDir', target))
},
targets: (targets || updateConfig.node.targets || TARGETS).map(t => {
targets: compact(options.targets || updateConfig.node.targets || TARGETS).map(t => {
const [platform, arch] = t.split('-') as [Config.PlatformTypes, Config.ArchTypes]
return {platform, arch}
}),
Expand Down

0 comments on commit c0a1fbb

Please sign in to comment.