UNPKG

1.09 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const Listr = require("listr");
4const util = require("util");
5const exec = util.promisify(require('child_process').exec);
6exports.default = ({ cwd }) => ({
7 title: 'Install dependencies',
8 task: async (_ctx, _task) => new Listr([
9 {
10 title: 'npm/yarn lookup',
11 task: async (ctx, task) => exec('yarn -v')
12 .then(() => {
13 ctx.yarn = true;
14 })
15 .catch(() => {
16 ctx.yarn = false;
17 task.skip('Yarn not available, install it via `npm install -g yarn`');
18 })
19 },
20 {
21 title: 'Installing integration dependencies with yarn',
22 enabled: (ctx) => ctx.yarn === true,
23 task: async (_ctx, _task) => exec('yarn install', { cwd })
24 },
25 {
26 title: 'Installing integration dependencies with npm',
27 enabled: (ctx) => ctx.yarn === false,
28 task: async () => exec('npm install', { cwd })
29 }
30 ])
31});