Skip to content

Commit

Permalink
feat: set permissions on binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jun 8, 2020
1 parent b9b27af commit 05b92d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ export async function build({ packages, ...options }: BuildCommandOptions) {
// Step 3: Link dependencies and Fix packages
pkg.syncLinkedDependencies()
pkg.autoFix()
pkg.writePackage()
await Promise.all([...pkg.setBinaryPermissions(), pkg.writePackage()])
})
performance.mark('Stop build')
if (watch) return

performance.mark('Stop build')
performance.measure('Finished build', 'Start build', 'Stop build')
}
24 changes: 23 additions & 1 deletion packages/core/src/package/package.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { dirname, resolve } from 'path'
import { readJSONSync, writeFile, copy, remove, existsSync } from 'fs-extra'
import {
chmod,
copy,
existsSync,
readJSONSync,
remove,
writeFile,
} from 'fs-extra'

import consola, { Consola } from 'consola'
import { bold, gray } from 'chalk'
Expand Down Expand Up @@ -389,6 +396,20 @@ export class Package {
}
}

get binaries() {
const { bin } = this.pkg
const files = !bin
? []
: typeof bin === 'string'
? [bin]
: Object.values(bin)
return Array.from(new Set(files.map(file => this.resolvePath(file))))
}

setBinaryPermissions() {
return this.binaries.map(file => chmod(file, 0o777))
}

async getWorkspacePackages(packageNames?: string[]) {
const packages: Package[] = []

Expand All @@ -402,6 +423,7 @@ export class Package {
for (const dir of dirs) {
if (existsSync(this.resolvePath(dir, 'package.json'))) {
const pkg = new Package({
...this.options,
rootDir: this.resolvePath(dir),
})
if (!packageNames || packageNames.includes(pkg.pkg.name)) {
Expand Down

0 comments on commit 05b92d1

Please sign in to comment.