cli: report relative path from inside the node_modules

This commit is contained in:
Gleb Bahmutov
2017-06-19 18:20:06 -04:00
parent a688c5c227
commit 996bf560fa
2 changed files with 25 additions and 1 deletions
+9 -1
View File
@@ -10,6 +10,7 @@ const debug = require('debug')('cypress:cli')
const { formErrorText, errors } = require('./errors')
const { stripIndent } = require('common-tags')
const R = require('ramda')
const pkg = require('../../package.json')
const unzip = require('./unzip')
const utils = require('./utils')
@@ -134,8 +135,15 @@ const logErr = (options) => (err) => {
.then(printAndFail)
}
const truePwd = () => {
const cwd = process.cwd()
return _.endsWith(cwd, pkg.name) ? path.join('..', '..') : cwd
}
const logFinish = (options) => {
const relativeExecutable = path.relative(process.cwd(), options.executable)
const currDirectory = truePwd()
debug('Current caller directory %s', currDirectory)
const relativeExecutable = path.relative(currDirectory, options.executable)
/* eslint-disable no-console */
console.log(
+16
View File
@@ -1,6 +1,7 @@
require('../spec_helper')
const nock = require('nock')
const path = require('path')
const Promise = require('bluebird')
const fs = Promise.promisifyAll(require('fs-extra'))
@@ -9,9 +10,12 @@ const unzip = require('../../lib/download/unzip')
const utils = require('../../lib/download//utils')
describe('download', function () {
const rootFolder = '/home/user/git'
beforeEach(function () {
this.options = { displayOpen: false }
this.sandbox.stub(process, 'exit')
this.sandbox.stub(process, 'cwd').returns(rootFolder)
this.sandbox.stub(unzip, 'start').resolves()
this.sandbox.stub(unzip, 'logErr').resolves()
this.sandbox.stub(unzip, 'cleanup').resolves()
@@ -129,6 +133,18 @@ describe('download', function () {
})
})
it('the reported path is relative', function () {
const appAt = 'node_modules/cypress/dist/Cypress.app'
this.sandbox.stub(utils, 'getPathToUserExecutable')
.returns(path.join(rootFolder, appAt))
return download.start(this.options)
.then(() => {
const logged = this.console.getCall(1).args.join()
expect(logged).to.include(appAt)
})
})
it.skip('displays opening app message', function () {
return download.start(this.options)
.then(() => {