import fs = require ( 'mz/fs' ) ; import path = require ( 'path' ) ; import { install } from 'supi' ; import tape = require ( 'tape' ) ; import promisifyTape from 'tape-promise' ; import { prepare , testDefaults , } from '../utils' ; const test = promisifyTape ( tape ) ; test ( 'production install (with --production flag)' , async ( t ) => { const project = prepare ( t , { dependencies : { rimraf : '2.6.2' , } , devDependencies : { '@rstacruz/tap-spec' : '4.1.1' , 'once' : '^1.4.0' , } , } ) ; await install ( await testDefaults ( { development : false } ) ) ; const rimraf = project . requireModule ( 'rimraf' ) ; let tapStatErrCode = 0 ; try { fs . statSync ( path . resolve ( 'node_modules' , '@rstacruz' ) ) ; } catch ( err ) { tapStatErrCode = err . code ; } t . ok ( rimraf , 'rimraf exists' ) ; t . is ( tapStatErrCode , 'ENOENT' , 'tap-spec does not exist' ) ; } ) ; test ( 'install dev dependencies only' , async ( t ) => { const project = prepare ( t , { dependencies : { 'is-positive' : '1.0.0' , 'once' : '^1.4.0' , } , devDependencies : { inflight : '1.0.6' , } , } ) ; await install ( await testDefaults ( { production : false } ) ) ; const inflight = project . requireModule ( 'inflight' ) ; t . equal ( typeof inflight , 'function' , 'dev dependency is available' ) ; await project . hasNot ( 'once' ) ; { const shr = await project . loadShrinkwrap ( ) ; t . ok ( shr . packages [ '/is-positive/1.0.0' ] . dev === false ) ; } { const currentShrinkwrap = await project . loadCurrentShrinkwrap ( ) ; t . notOk ( currentShrinkwrap . packages [ '/is-positive/1.0.0' ] , 'prod dep only not added to current shrinkwrap.yaml' ) ; } await install ( await testDefaults ( ) ) ; await project . has ( 'once' ) ; { const currentShrinkwrap = await project . loadCurrentShrinkwrap ( ) ; t . ok ( currentShrinkwrap . packages [ '/is-positive/1.0.0' ] , 'prod dep added to current shrinkwrap.yaml' ) ; } } ) ;