Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
feat(bin): link bins and run scripts (#25)
Browse files Browse the repository at this point in the history
Fixes: #4
  • Loading branch information
zkat authored Oct 9, 2017
1 parent 68ecfac commit fab74bf
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 4 deletions.
18 changes: 16 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

const BB = require('bluebird')

const binLink = require('bin-links')
const config = require('./lib/config.js')
const extract = require('./lib/extract.js')
const fs = require('graceful-fs')
const getPrefix = require('./lib/get-prefix.js')
const lifecycle = require('npm-lifecycle')
const lockVerify = require('lock-verify')
const path = require('path')
const logi = require('npm-logical-tree')
const npmlog = require('npmlog')
const path = require('path')
const readPkgJson = BB.promisify(require('read-package-json'))
const rimraf = BB.promisify(require('rimraf'))

const readFileAsync = BB.promisify(fs.readFile)
Expand All @@ -24,6 +27,7 @@ class Installer {
this.pkgCount = 0

// Misc
this.log = npmlog
this.pkg = null
}

Expand Down Expand Up @@ -111,10 +115,20 @@ class Installer {
)
child.pending = BB.resolve()
.then(() => extract.child(child.name, child, childPath, this.config))
.then(() => readJson(childPath, 'package.json'))
.then(() => readPkgJson(path.join(childPath, 'package.json')))
.then(pkg => {
return this.runScript('preinstall', pkg, childPath)
.then(() => this.extractTree(child))
.then(() => binLink(pkg, childPath, false, {
force: this.config.config.force,
ignoreScripts: this.config.lifecycleOpts.ignoreScripts,
log: this.log,
name: pkg.name,
pkgId: pkg.name + '@' + pkg.version,
prefix: this.prefix,
prefixes: [this.prefix],
umask: this.config.config.umask
}), e => {})
.then(() => this.runScript('install', pkg, childPath))
.then(() => this.runScript('postinstall', pkg, childPath))
.then(() => {
Expand Down
75 changes: 73 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"license": "MIT",
"dependencies": {
"bin-links": "^1.0.0",
"bluebird": "^3.5.0",
"graceful-fs": "^4.1.11",
"lock-verify": "^1.1.0",
Expand All @@ -41,6 +42,7 @@
"npm-package-arg": "^5.1.2",
"npmlog": "^4.1.2",
"pacote": "^6.0.2",
"read-package-json": "^2.0.12",
"rimraf": "^2.6.1",
"worker-farm": "^1.5.0",
"yargs": "^8.0.2"
Expand Down

0 comments on commit fab74bf

Please sign in to comment.