Skip to content
This repository has been archived by the owner on Nov 3, 2019. It is now read-only.

Commit

Permalink
feat(CLI): use the local install of mos when available
Browse files Browse the repository at this point in the history
close #65
  • Loading branch information
zkochan committed May 8, 2016
1 parent 08ad837 commit a42d72c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ mos test --tap | tap-nyan

![](http://i.imgur.com/jet4ZAG.png?2)

**NOTE:** the CLI will use your local install of mos when available, even when run globally.

## API Usage

<!--@example('example.js')-->
Expand Down
19 changes: 16 additions & 3 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ process.on('unhandledRejection', function (reason, p) {
reason)
})

const resolve = require('resolve')
const cwd = process.cwd()

let localCLI
try {
localCLI = resolve.sync('mos/lib/cli', { basedir: cwd })
} catch (err) {
localCLI = __filename
}

if (localCLI && localCLI !== __filename) {
console.log('Using local install of mos')
require(localCLI)
return // eslint-disable-line
}

const updateNotifier = require('update-notifier')
const meow = require('meow')
const processFiles = require('./process-files')
Expand All @@ -18,7 +34,6 @@ const path = require('path')
const test = require('tape')
const tapDiff = require('@zkochan/tap-diff')
const readPkgUp = require('@zkochan/read-pkg-up')
const resolve = require('resolve')
const mos = require('.')
const initCustomPlugins = require('./init-custom-plugins')

Expand Down Expand Up @@ -62,8 +77,6 @@ const highlightPath = chalk.bgBlack.yellow

const isTest = ~['test', 't'].indexOf((cli.input[0] || '').toLowerCase())

const cwd = process.cwd()

readPkgUp({ cwd })
.then(result => {
const pkgPlugins = Object
Expand Down

0 comments on commit a42d72c

Please sign in to comment.