1 line
2.7 KiB
Plaintext
1 line
2.7 KiB
Plaintext
{"version":3,"sources":["install.js"],"names":["appPath","packageName","packageVersion","options","join","useYarn","command","args","pkg","push","npmOrYarn","spawnOpts","silent","stdio","proc","on","resolve","code","install"],"mappings":";;;;;;;;;;;;;;;;;;AAEA;;;;AACA;;;;AACA;;;;AACA;;;;;;;sFAQgB,iBACdA,OADc,EAEdC,WAFc,EAGdC,cAHc;AAAA,QAIdC,OAJc,uEAIE,EAJF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAMiB,0BAAW,eAAKC,IAAL,CAAUJ,OAAV,EAAmB,WAAnB,CAAX,CANjB;;AAAA;AAMRK,mBANQ;AAQVC,mBARU,GAQA,EARA;AASVC,gBATU,GASH,EATG;;;AAWd,gBAAIF,OAAJ,EAAa;AACXC,wBAAU,SAAV;AACA,kBAAIL,WAAJ,EAAiB;AACfM,uBAAO,CAAC,KAAD,CAAP;AACD;AACF,aALD,MAKO;AACLD,wBAAU,KAAV;AACAC,qBAAO,CAAC,SAAD,EAAY,QAAZ,CAAP;;AAEA;AACA;AACA;AACD;;AAEGC,eAzBU,GAyBJP,WAzBI;;AA0Bd,gBAAIO,GAAJ,EAAS;AACP,kBAAIN,cAAJ,EAAoB;AAClBM,sBAASA,GAAT,SAAgBN,cAAhB;AACD;;AAEDK,mBAAKE,IAAL,CAAUD,GAAV;AACD;;AAEKE,qBAlCQ,GAkCIL,UAAU,MAAV,GAAmB,KAlCvB;;AAmCd,gDAAkBG,MAAMA,GAAN,GAAY,cAA9B,gBAAsDE,SAAtD;AACA;;AAEIC,qBAtCU,GAsCE,EAtCF;;AAuCd,gBAAIR,QAAQS,MAAZ,EAAoB;AAClBD,wBAAUC,MAAV,GAAmB,IAAnB;AACD,aAFD,MAEO;AACLD,wBAAUE,KAAV,GAAkB,SAAlB;AACD;;AAEKC,gBA7CQ,GA6CD,0BAAMR,OAAN,EAAeC,IAAf,EAAqBI,SAArB,CA7CC;AAAA,6CA8CP,sBAAY,mBAAW;AAC5BG,mBAAKC,EAAL,CAAQ,OAAR,EAAiB;AAAA,uBAAQC,QAAQ,EAAEC,UAAF,EAAQX,gBAAR,EAAiBC,UAAjB,EAAR,CAAR;AAAA,eAAjB;AACD,aAFM,CA9CO;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;WAAeW,O;;;;SAAAA,O","file":"install.js","sourcesContent":["// @flow\n\nimport spawn from 'cross-spawn';\nimport pathExists from 'path-exists';\nimport path from 'path';\nimport log from '../util/log';\n\ntype InstallResult = {\n code: number,\n command: string,\n args: Array<string>,\n};\n\nexport default (async function install(\n appPath: string,\n packageName?: string,\n packageVersion?: string,\n options?: any = {}\n): Promise<InstallResult> {\n const useYarn: boolean = await pathExists(path.join(appPath, 'yarn.lock'));\n\n let command = '';\n let args = [];\n\n if (useYarn) {\n command = 'yarnpkg';\n if (packageName) {\n args = ['add'];\n }\n } else {\n command = 'npm';\n args = ['install', '--save'];\n\n // if (verbose) {\n // args.push('--verbose');\n // }\n }\n\n let pkg = packageName;\n if (pkg) {\n if (packageVersion) {\n pkg = `${pkg}@${packageVersion}`;\n }\n\n args.push(pkg);\n }\n\n const npmOrYarn = useYarn ? 'yarn' : 'npm';\n log(`Installing ${pkg ? pkg : 'dependencies'} using ${npmOrYarn}...`);\n log();\n\n let spawnOpts = {};\n if (options.silent) {\n spawnOpts.silent = true;\n } else {\n spawnOpts.stdio = 'inherit';\n }\n\n const proc = spawn(command, args, spawnOpts);\n return new Promise(resolve => {\n proc.on('close', code => resolve({ code, command, args }));\n });\n});\n"]} |