UNPKG

gl-vsts-tasks-build-scripts

Version:

This package provides NPM utility commands to ease Azure Pipelines Tasks extensions developement. This currently powers the development process behind Geek Learning's extensions.

42 lines (41 loc) 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var fs = require("fs-extra"); var lodash_1 = require("lodash"); var path = require("path"); var tasks = require("./tasks"); var currentDirectory = process.cwd(); var nodeCommonFilesRoot = path.join(currentDirectory, "Common", "Node"); var powershellCommonFilesRoot = path.join(currentDirectory, "Common", "PowerShell3"); var nodeFiles = fs.existsSync(nodeCommonFilesRoot) ? fs.readdirSync(nodeCommonFilesRoot) : []; var powershellFiles = fs.existsSync(powershellCommonFilesRoot) ? fs.readdirSync(powershellCommonFilesRoot) : []; lodash_1.forEach(tasks.getTasks(), function (task) { var targetNodeCommonDir = path.join(task.directory, "common"); var taskNodeModules = path.join(task.directory, "node_modules"); var targetPowershellCommonDir = path.join(task.directory, "ps_modules"); var taskFilePath = path.join(task.directory, "task.json"); var taskFile = fs.existsSync(taskFilePath) ? fs.readJsonSync(taskFilePath) : {}; if (taskFile.execution.Node || taskFile.execution.Node10) { fs.ensureDirSync(targetNodeCommonDir); fs.ensureDirSync(taskNodeModules); lodash_1.forEach(nodeFiles, function (commonFile) { var targetFile = path.join(targetNodeCommonDir, commonFile); console.log(targetFile); fs.copySync(path.join(nodeCommonFilesRoot, commonFile), targetFile, { overwrite: true, errorOnExist: false, }); }); } if (taskFile.execution.PowerShell3) { fs.ensureDirSync(targetPowershellCommonDir); lodash_1.forEach(powershellFiles, function (commonFile) { var targetFile = path.join(targetPowershellCommonDir, commonFile); console.log(targetFile); fs.copySync(path.join(powershellCommonFilesRoot, commonFile), targetFile, { overwrite: true, errorOnExist: false, }); }); } });