How to use workingDir method in stryker-parent

Best JavaScript code snippet using stryker-parent

index.js

Source:index.js Github

copy

Full Screen

1module.exports = wrap2wrap.runMain = runMain3var Module = require('module')4var fs = require('fs')5var cp = require('child_process')6var ChildProcess = cp.ChildProcess7var assert = require('assert')8var crypto = require('crypto')9var mkdirp = require('mkdirp')10var rimraf = require('rimraf')11var path = require('path')12var signalExit = require('signal-exit')13var home = process.env.SPAWN_WRAP_SHIM_ROOT || require('os-homedir')()14var homedir = home + '/.node-spawn-wrap-'15var which = require('which')16var util = require('util')17var doDebug = process.env.SPAWN_WRAP_DEBUG === '1'18var debug = doDebug ? function () {19 var message = util.format.apply(util, arguments).trim()20 var pref = 'SW ' + process.pid + ': '21 message = pref + message.split('\n').join('\n' + pref)22 process.stderr.write(message + '\n')23} : function () {}24var shebang = process.platform === 'os390' ?25 '#!/bin/env ' : '#!'26var shim = shebang + process.execPath + '\n' +27 fs.readFileSync(__dirname + '/shim.js')28var isWindows = require('./lib/is-windows')()29var pathRe = /^PATH=/30if (isWindows) pathRe = /^PATH=/i31var colon = isWindows ? ';' : ':'32function wrap (argv, env, workingDir) {33 if (!ChildProcess) {34 var child = cp.spawn(process.execPath, [])35 ChildProcess = child.constructor36 if (process.platform === 'os390')37 child.kill('SIGABRT')38 else39 child.kill('SIGKILL')40 }41 // spawn_sync available since Node v0.1142 var spawnSyncBinding, spawnSync43 try {44 spawnSyncBinding = process.binding('spawn_sync')45 } catch (e) {}46 // if we're passed in the working dir, then it means that setup47 // was already done, so no need.48 var doSetup = !workingDir49 if (doSetup) {50 workingDir = setup(argv, env)51 }52 var spawn = ChildProcess.prototype.spawn53 if (spawnSyncBinding) {54 spawnSync = spawnSyncBinding.spawn55 }56 function unwrap () {57 if (doSetup && !doDebug) {58 rimraf.sync(workingDir)59 }60 ChildProcess.prototype.spawn = spawn61 if (spawnSyncBinding) {62 spawnSyncBinding.spawn = spawnSync63 }64 }65 if (spawnSyncBinding) {66 spawnSyncBinding.spawn = wrappedSpawnFunction(spawnSync, workingDir)67 }68 ChildProcess.prototype.spawn = wrappedSpawnFunction(spawn, workingDir)69 return unwrap70}71function wrappedSpawnFunction (fn, workingDir) {72 return wrappedSpawn73 function wrappedSpawn (options) {74 munge(workingDir, options)75 debug('WRAPPED', options)76 return fn.call(this, options)77 }78}79function isSh (file) {80 return file === 'dash' ||81 file === 'sh' ||82 file === 'bash' ||83 file === 'zsh'84}85function mungeSh (workingDir, options) {86 var cmdi = options.args.indexOf('-c')87 if (cmdi === -1)88 return // no -c argument89 var c = options.args[cmdi + 1]90 var re = /^\s*((?:[^\= ]*\=[^\=\s]*)*[\s]*)([^\s]+|"[^"]+"|'[^']+')( .*)?$/91 var match = c.match(re)92 if (!match)93 return // not a command invocation. weird but possible94 var command = match[2]95 // strip quotes off the command96 var quote = command.charAt(0)97 if ((quote === '"' || quote === '\'') && quote === command.slice(-1)) {98 command = command.slice(1, -1)99 }100 var exe = path.basename(command)101 if (isNode(exe)) {102 options.originalNode = command103 c = match[1] + match[2] + ' "' + workingDir + '/node" ' + match[3]104 options.args[cmdi + 1] = c105 } else if (exe === 'npm' && !isWindows) {106 // XXX this will exhibit weird behavior when using /path/to/npm,107 // if some other npm is first in the path.108 var npmPath = whichOrUndefined('npm')109 if (npmPath) {110 c = c.replace(re, '$1 "' + workingDir + '/node" "' + npmPath + '" $3')111 options.args[cmdi + 1] = c112 debug('npm munge!', c)113 }114 }115}116function isCmd (file) {117 var comspec = path.basename(process.env.comspec || '').replace(/\.exe$/i, '')118 return isWindows && (file === comspec || /^cmd(\.exe|\.EXE)?$/.test(file))119}120function mungeCmd (workingDir, options) {121 var cmdi = options.args.indexOf('/c')122 if (cmdi === -1)123 return124 var re = /^\s*("*)([^"]*?\b(?:node|iojs)(?:\.exe|\.EXE)?)("*)( .*)?$/125 var npmre = /^\s*("*)([^"]*?\b(?:npm))("*)( |$)/126 var path_ = require('path')127 if (path_.win32)128 path_ = path_.win32129 var command = options.args[cmdi + 1]130 if (!command)131 return132 var m = command.match(re)133 var replace134 if (m) {135 options.originalNode = m[2]136 replace = m[1] + workingDir + '/node.cmd' + m[3] + m[4]137 options.args[cmdi + 1] = m[1] + m[2] + m[3] +138 ' "' + workingDir + '\\node"' + m[4]139 } else {140 // XXX probably not a good idea to rewrite to the first npm in the141 // path if it's a full path to npm. And if it's not a full path to142 // npm, then the dirname will not work properly!143 m = command.match(npmre)144 if (!m)145 return146 var npmPath = whichOrUndefined('npm') || 'npm'147 npmPath = path_.dirname(npmPath) + '\\node_modules\\npm\\bin\\npm-cli.js'148 replace = m[1] + workingDir + '/node.cmd' +149 ' "' + npmPath + '"' +150 m[3] + m[4]151 options.args[cmdi + 1] = command.replace(npmre, replace)152 }153}154function isNode (file) {155 var cmdname = path.basename(process.execPath).replace(/\.exe$/i, '')156 return file === 'node' || file === 'iojs' || cmdname === file157}158function mungeNode (workingDir, options) {159 options.originalNode = options.file160 var command = path.basename(options.file).replace(/\.exe$/i, '')161 // make sure it has a main script.162 // otherwise, just let it through.163 var a = 0164 var hasMain = false165 var mainIndex = 1166 for (var a = 1; !hasMain && a < options.args.length; a++) {167 switch (options.args[a]) {168 case '-p':169 case '-i':170 case '--interactive':171 case '--eval':172 case '-e':173 case '-pe':174 hasMain = false175 a = options.args.length176 continue177 case '-r':178 case '--require':179 a += 1180 continue181 default:182 if (options.args[a].match(/^-/)) {183 continue184 } else {185 hasMain = true186 mainIndex = a187 a = options.args.length188 break189 }190 }191 }192 if (hasMain) {193 var replace = workingDir + '/' + command194 options.args.splice(mainIndex, 0, replace)195 }196 // If the file is just something like 'node' then that'll197 // resolve to our shim, and so to prevent double-shimming, we need198 // to resolve that here first.199 // This also handles the case where there's not a main file, like200 // `node -e 'program'`, where we want to avoid the shim entirely.201 if (options.file === options.basename) {202 var realNode = whichOrUndefined(options.file) || process.execPath203 options.file = options.args[0] = realNode204 }205 debug('mungeNode after', options.file, options.args)206}207function mungeShebang (workingDir, options) {208 try {209 var resolved = which.sync(options.file)210 } catch (er) {211 // nothing to do if we can't resolve212 // Most likely: file doesn't exist or is not executable.213 // Let exec pass through, probably will fail, oh well.214 return215 }216 var shebang = fs.readFileSync(resolved, 'utf8')217 var match = shebang.match(/^#!([^\r\n]+)/)218 if (!match)219 return // not a shebang script, probably a binary220 var shebangbin = match[1].split(' ')[0]221 var maybeNode = path.basename(shebangbin)222 if (!isNode(maybeNode))223 return // not a node shebang, leave untouched224 options.originalNode = shebangbin225 options.basename = maybeNode226 options.file = shebangbin227 options.args = [shebangbin, workingDir + '/' + maybeNode]228 .concat(resolved)229 .concat(match[1].split(' ').slice(1))230 .concat(options.args.slice(1))231}232function mungeEnv (workingDir, options) {233 var pathEnv234 for (var i = 0; i < options.envPairs.length; i++) {235 var ep = options.envPairs[i]236 if (ep.match(pathRe)) {237 pathEnv = ep.substr(5)238 var k = ep.substr(0, 5)239 options.envPairs[i] = k + workingDir + colon + pathEnv240 }241 }242 if (!pathEnv) {243 options.envPairs.push((isWindows ? 'Path=' : 'PATH=') + workingDir)244 }245 if (options.originalNode) {246 var key = path.basename(workingDir).substr('.node-spawn-wrap-'.length)247 options.envPairs.push('SW_ORIG_' + key + '=' + options.originalNode)248 }249 options.envPairs.push('SPAWN_WRAP_SHIM_ROOT=' + homedir)250 if (process.env.SPAWN_WRAP_DEBUG === '1')251 options.envPairs.push('SPAWN_WRAP_DEBUG=1')252}253function isnpm (file) {254 // XXX is this even possible/necessary?255 // wouldn't npm just be detected as a node shebang?256 return file === 'npm' && !isWindows257}258function mungenpm (workingDir, options) {259 debug('munge npm')260 // XXX weird effects of replacing a specific npm with a global one261 var npmPath = whichOrUndefined('npm')262 if (npmPath) {263 options.args[0] = npmPath264 options.file = workingDir + '/node'265 options.args.unshift(workingDir + '/node')266 }267}268function munge (workingDir, options) {269 options.basename = path.basename(options.file).replace(/\.exe$/i, '')270 // XXX: dry this271 if (isSh(options.basename)) {272 mungeSh(workingDir, options)273 } else if (isCmd(options.basename)) {274 mungeCmd(workingDir, options)275 } else if (isNode(options.basename)) {276 mungeNode(workingDir, options)277 } else if (isnpm(options.basename)) {278 // XXX unnecessary? on non-windows, npm is just another shebang279 mungenpm(workingDir, options)280 } else {281 mungeShebang(workingDir, options)282 }283 // now the options are munged into shape.284 // whether we changed something or not, we still update the PATH285 // so that if a script somewhere calls `node foo`, it gets our286 // wrapper instead.287 mungeEnv(workingDir, options)288}289function whichOrUndefined (executable) {290 var path291 try {292 path = which.sync(executable)293 } catch (er) {}294 return path295}296function setup (argv, env) {297 if (argv && typeof argv === 'object' && !env && !Array.isArray(argv)) {298 env = argv299 argv = []300 }301 if (!argv && !env) {302 throw new Error('at least one of "argv" and "env" required')303 }304 if (argv) {305 assert(Array.isArray(argv), 'argv must be array')306 } else {307 argv = []308 }309 if (env) {310 assert(typeof env === 'object', 'env must be an object')311 } else {312 env = {}313 }314 debug('setup argv=%j env=%j', argv, env)315 // For stuff like --use_strict or --harmony, we need to inject316 // the argument *before* the wrap-main.317 var execArgv = []318 for (var i = 0; i < argv.length; i++) {319 if (argv[i].match(/^-/)) {320 execArgv.push(argv[i])321 if (argv[i] === '-r' || argv[i] === '--require') {322 execArgv.push(argv[++i])323 }324 } else {325 break326 }327 }328 if (execArgv.length) {329 if (execArgv.length === argv.length) {330 argv.length = 0331 } else {332 argv = argv.slice(execArgv.length)333 }334 }335 var key = process.pid + '-' + crypto.randomBytes(6).toString('hex')336 var workingDir = homedir + key337 var settings = JSON.stringify({338 module: __filename,339 deps: {340 foregroundChild: require.resolve('foreground-child'),341 signalExit: require.resolve('signal-exit'),342 },343 key: key,344 workingDir: workingDir,345 argv: argv,346 execArgv: execArgv,347 env: env,348 root: process.pid349 }, null, 2) + '\n'350 signalExit(function () {351 if (!doDebug)352 rimraf.sync(workingDir)353 })354 mkdirp.sync(workingDir)355 workingDir = fs.realpathSync(workingDir)356 if (isWindows) {357 var cmdShim =358 '@echo off\r\n' +359 'SETLOCAL\r\n' +360 'CALL :find_dp0\r\n' +361 'SET PATHEXT=%PATHEXT:;.JS;=;%\r\n' +362 '"' + process.execPath + '"' + ' "%dp0%node" %*\r\n' +363 'EXIT /b %errorlevel%\r\n'+364 ':find_dp0\r\n' +365 'SET dp0=%~dp0\r\n' +366 'EXIT /b\r\n'367 fs.writeFileSync(workingDir + '/node.cmd', cmdShim)368 fs.chmodSync(workingDir + '/node.cmd', '0755')369 fs.writeFileSync(workingDir + '/iojs.cmd', cmdShim)370 fs.chmodSync(workingDir + '/iojs.cmd', '0755')371 }372 fs.writeFileSync(workingDir + '/node', shim)373 fs.chmodSync(workingDir + '/node', '0755')374 fs.writeFileSync(workingDir + '/iojs', shim)375 fs.chmodSync(workingDir + '/iojs', '0755')376 var cmdname = path.basename(process.execPath).replace(/\.exe$/i, '')377 if (cmdname !== 'iojs' && cmdname !== 'node') {378 fs.writeFileSync(workingDir + '/' + cmdname, shim)379 fs.chmodSync(workingDir + '/' + cmdname, '0755')380 }381 fs.writeFileSync(workingDir + '/settings.json', settings)382 return workingDir383}384function runMain () {385 process.argv.splice(1, 1)386 process.argv[1] = path.resolve(process.argv[1])387 delete require.cache[process.argv[1]]388 Module.runMain()...

Full Screen

Full Screen

gulpfile.js

Source:gulpfile.js Github

copy

Full Screen

1'use strict';2var gulp = require('gulp'),3 fs = require('fs'),4 runSeq = require('run-sequence'),5 $ = require('gulp-load-plugins')({6 rename: {7 'gulp-ruby-sass': 'sass',8 'gulp-clean-css': 'cleanCSS',9 'gulp-uglify' : 'compress'10 }11 });12 $.fs = fs;13 $.path = require('path');14 $.prompt = require('prompt');15 $.inquirer = require('inquirer');16/**17 * Get configuration18 */19var env = {20 config: JSON.parse(fs.readFileSync('./config.json'))21};22var workingdir = {}; // will be completed by the setWorkingDir function23/**24 * Set paths relative to the theme directory25 */26function setWorkingDir() {27 Object.keys(env.config.paths.themePath).map(function(k, i) {28 workingdir[k] = './' + env.config.paths.themePath[k];29 });30}31gulp.task('compile:all', function () {32 var css = env.config.cssProcessor === 'less'?'less':'scss';33 runSeq('bootstrap-js','vendors','js',css);34});35/**36 * Gulp task: bootstrap-js37 *38 * Compile bootstrap js files to bootstrap.min.js39 */40gulp.task('bootstrap-js', function () {41 gulp.src([42 env.workingDir.vendor + '/bootstrap/transition.js',43 env.workingDir.vendor + '/bootstrap/alert.js',44 //env.workingDir.vendor + '/bootstrap/button.js',45 env.workingDir.vendor + '/bootstrap/carousel.js',46 env.workingDir.vendor + '/bootstrap/collapse.js',47 env.workingDir.vendor + '/bootstrap/dropdown.js',48 env.workingDir.vendor + '/bootstrap/modal.js',49 env.workingDir.vendor + '/bootstrap/tooltip.js',50 //env.workingDir.vendor + '/bootstrap/popover.js',51 //env.workingDir.vendor + '/bootstrap/scrollspy.js',52 env.workingDir.vendor + '/bootstrap/tab.js'53 //env.workingDir.vendor + '/bootstrap/affix.js'54 ])55 .pipe($.concat('bootstrap.js'))56 .pipe($.compress())57 .pipe($.rename({ suffix: '.min' }))58 .pipe($.header($.fs.readFileSync('Copyright'),{theme: {name: env.config.name, version: env.config.version, magixcms: env.config.magixcms}}))59 .pipe(gulp.dest(env.workingDir.vendor))60 .pipe(gulp.dest(env.config.paths.skins + '/' + env.config.name + '/js/vendor'));61 gulp.src([62 env.workingDir.vendor + '/bootstrap/transition.js',63 env.workingDir.vendor + '/bootstrap/alert.js',64 //env.workingDir.vendor + '/bootstrap/button.js',65 //env.workingDir.vendor + '/bootstrap/carousel.js',66 env.workingDir.vendor + '/bootstrap/collapse.js',67 env.workingDir.vendor + '/bootstrap/dropdown.js',68 env.workingDir.vendor + '/bootstrap/modal.js',69 //env.workingDir.vendor + '/bootstrap/tooltip.js',70 //env.workingDir.vendor + '/bootstrap/popover.js',71 //env.workingDir.vendor + '/bootstrap/scrollspy.js',72 env.workingDir.vendor + '/bootstrap/tab.js'73 //env.workingDir.vendor + '/bootstrap/affix.js'74 ])75 .pipe($.concat('bootstrap-mobile.js'))76 .pipe($.compress())77 .pipe($.rename({ suffix: '.min' }))78 .pipe($.header($.fs.readFileSync('Copyright'),{theme: {name: env.config.name, version: env.config.version, magixcms: env.config.magixcms}}))79 .pipe(gulp.dest(env.workingDir.vendor))80 .pipe(gulp.dest(env.config.paths.skins + '/' + env.config.name + '/js/vendor'));81});82/**83 * Gulp task: vendors84 *85 * Compile js vendor sources into .min86 */87gulp.task('vendors', function () {88 gulp.src(env.workingDir.vendorSrc + '/*.js')89 .pipe($.compress())90 .pipe($.rename({ suffix: '.min' }))91 .pipe($.header($.fs.readFileSync('Copyright'),{theme: {name: env.config.name, version: env.config.version, magixcms: env.config.magixcms}}))92 .pipe(gulp.dest(env.workingDir.vendor))93 .pipe(gulp.dest(env.config.paths.skins + '/' + env.config.name + '/js/vendor'));94});95/**96 * Gulp task:js97 *98 * Compile js sources into .min99 */100gulp.task('js', function () {101 gulp.src(env.workingDir.jsSrc + '/*.js')102 .pipe($.compress())103 .pipe($.rename({ suffix: '.min' }))104 .pipe($.header($.fs.readFileSync('Copyright'),{theme: {name: env.config.name, version: env.config.version, magixcms: env.config.magixcms}}))105 .pipe(gulp.dest(env.workingDir.js))106 .pipe(gulp.dest(env.config.paths.skins + '/' + env.config.name + '/js'));107});108/**109 * Gulp task: scss110 *111 * Compile scss files into .min.css112 */113gulp.task('scss', function () {114 var globs, msg;115 if (typeof $.util.env.cssFile == 'undefined') {116 msg = 'Compilation and Minification of all css files';117 globs = [env.workingDir.less + '/style.less', env.workingDir.less + '/mobile.less'];118 }119 else {120 msg = 'Compilation and Minification of ' + $.util.env.cssFile + '.css';121 globs = env.workingDir.less + '/' + $.util.env.cssFile + '.less';122 }123 return $.sass(globs, {124 style: 'compressed',125 loadPath: [126 env.workingDir.scss,127 env.workingDir.css + '/bootstrap/scss',128 env.workingDir.css + '/font-awesome/scss'129 ]130 })131 .on("error", notify.onError(function (error) {132 return "Error: " + error.message;133 }))134 .pipe($.notify(msg))135 .pipe($.rename({ suffix: '.min' }))136 .pipe($.header($.fs.readFileSync('Copyright'),{theme: {name: env.config.name, version: env.config.version, magixcms: env.config.magixcms}}))137 .pipe(gulp.dest(env.workingDir.css));138});139/**140 * Gulp task: less141 *142 * Compile less files into .min.css143 */144gulp.task('less', function () {145 var globs, msg;146 if (typeof env.config.cssFile === 'undefined') {147 msg = 'Compilation and Minification of all css files';148 globs = [env.workingDir.less + '/style.less', env.workingDir.less + '/mobile.less'];149 }150 else {151 msg = 'Compilation and Minification of ' + env.config.cssFile + '.css';152 globs = env.workingDir.less + '/' + env.config.cssFile + '.less';153 }154 return gulp.src(globs)155 .pipe($.notify(msg))156 .pipe($.less({157 paths: [158 env.workingDir.less,159 env.workingDir.css + '/bootstrap/less',160 env.workingDir.css + '/font-awesome/less',161 env.workingDir.css + '/fancybox'162 ],163 compress: true164 }))165 .pipe($.rename({ suffix: '.min' }))166 .pipe($.header($.fs.readFileSync('Copyright'),{theme: {name: env.config.name, version: env.config.version, magixcms: env.config.magixcms}}))167 .pipe(gulp.dest(env.workingDir.css))168 .pipe(gulp.dest(env.config.paths.skins + '/' + env.config.name + '/css'));169});170/**171 * gulp Task: watch-css172 *173 * File watcher for CSS files174 */175gulp.task('watch-css', function () {176 if(env.config.cssProcessor === 'less'177 || env.config.cssProcessor === 'scss')178 {179 var srcPath = workingdir.cssSrc + '/' + env.config.cssProcessor;180 gulp.watch([181 srcPath + '/style.' + env.config.cssProcessor,182 srcPath + '/**/*.' + env.config.cssProcessor,183 '!' + srcPath + 'custom/critical/mobile/*.' + env.config.cssProcessor,184 '!' + srcPath + 'custom/theme/mobile/*.' + env.config.cssProcessor,185 '!' + srcPath + '/mobile.' + env.config.cssProcessor186 ], [(env.config.cssProcessor)]).on('change', function() { env.config.cssFile = 'style'; });187 gulp.watch([188 srcPath + '/mobile.' + env.config.cssProcessor,189 srcPath + '/**/*.' + env.config.cssProcessor,190 '!' + srcPath + 'custom/critical/**/*.' + env.config.cssProcessor,191 '!' + srcPath + 'custom/theme/**/*.' + env.config.cssProcessor,192 srcPath + 'custom/critical/mobile/*.' + env.config.cssProcessor,193 srcPath + 'custom/theme/mobile/*.' + env.config.cssProcessor,194 '!' + srcPath + '/style.' + env.config.cssProcessor195 ], [(env.config.cssProcessor)]).on('change', function() { env.config.cssFile = 'mobile'; });196 }197});198/**199 * gulp Task: watch-vendors200 *201 * File watcher for JS Vendors files202 */203gulp.task('watch-vendors', function () {204 gulp.watch(workingdir.vendors + '/bootstrap/**/*.js', ['bootstrap-js']);205 gulp.watch(workingdir.vendorsSrc + '/**/*.js', ['vendors']);206});207/**208 * gulp Task: watch-js209 *210 * File watcher for JS files211 */212gulp.task('watch-js', function () {213 gulp.watch(workingdir.jsSrc + '/**/*.js', ['js']);214});215// --- All Watchers216/**217 * Gulp Task: watch218 *219 * Start file watchers for a theme220 *221 * If the theme does not exist,222 * it propose to create it223 */224gulp.task('watch', function (cb) {225 setWorkingDir();226 runSeq(['watch-css', 'watch-vendors', 'watch-js'], cb);227});228/**229 * Default Gulp task230 *231 * Ask for user what he want to do between:232 * - Start file watchers233 * - Update version234 * - Never mind235 */236gulp.task('default', function (cb) {237 var task_choices = [238 {239 type: "list",240 name: "task",241 message: "What do you want to do ?",242 choices: [243 {244 name: "Start file watchers",245 value: "watch"246 },247 {248 name: "Compile all file types",249 value: "compile:all"250 },251 new $.inquirer.Separator(),252 {253 name: "Update version",254 value: "patch"255 },256 new $.inquirer.Separator(),257 {258 name: "Never mind",259 value: "closing"260 }261 ]262 }263 ];264 $.inquirer.prompt(task_choices).then(function(result) {265 // Check if bower is installed266 runSeq(result.task, cb);267 });...

Full Screen

Full Screen

github.js

Source:github.js Github

copy

Full Screen

1/*2 * This program and the accompanying materials are made available under the terms of the3 * Eclipse Public License v2.0 which accompanies this distribution, and is available at4 * https://www.eclipse.org/legal/epl-v20.html5 *6 * SPDX-License-Identifier: EPL-2.07 *8 * Copyright IBM Corporation 20219 */10const utils = require('./utils.js')11class github {12 /**13 * Issue git command14 *15 * @param workingDir the working directory16 * @param command git command to issue17 */18 static _cmd(workingDir, command, quiet) {19 if (!workingDir) {20 console.warn('Git operation skipped, must specify working directory')21 } 22 else {23 var cmd=`git ${command}`24 const res = utils.sh(cmd, {cwd: workingDir})25 if (!quiet) {26 console.log('>>>', cmd, '\n', res, '\n<<<')27 } 28 return res29 }30 }31 /**32 * Validate if a tag exists in remote.33 *34 * @Example35 * <pre>36 * if (github.tagExistsRemote('v1.2.3')) {37 * echo "Tag v1.2.3 already exists in remote."38 * }39 * </pre>40 *41 * @param tag tag name to check42 * @return true/false43 */44 static tagExistsRemote(tag) {45 var remotedTags = utils.sh('git ls-remote --tags').split("\n")46 var foundTag = false47 remotedTags.forEach(eachtag => {48 if (eachtag.endsWith(`refs/tags/${tag}`)) { 49 foundTag = true 50 }51 })52 return foundTag53 }54 /**55 * Tag the branch and push to remote.56 *57 * @Note Currently only support lightweighted tag.58 *59 * @param tag tag name to be created60 */61 static tag(tag) {62 // init with arguments63 if (!tag) {64 throw new Error('tag name is missing, failed to tag')65 }66 console.log(utils.sh(`git tag "${tag}" && git push origin "${tag}"`))67 }68 /**69 * Clone a remote repository70 *71 * @param repo the repository name, required 72 * @param dir the directory name to place the clone, required73 * @param branch the branch name to be cloned, optional74 * @param shallow flag to do shallow clone (just clone latest one history), optional75 */76 static clone(repo, dir, branch, shallow) {77 if (!repo || !dir) {78 console.warn('Clone operation skipped, must specify both mandatory arguments: repo, dir')79 } 80 else {81 var cmd = `mkdir -p ${dir} && git clone`82 if (branch) {83 if (shallow) {84 cmd += ' --depth 1'85 }86 cmd += ` --single-branch --branch ${branch}`87 }88 var fullRepo = ` https://github.com/${repo}.git ${dir}`89 cmd += fullRepo90 utils.sh(cmd)91 }92 }93 /**94 * Hard reset a repository, removing all (/staged) changes95 *96 * @param branch the branch name to be reset, required97 * @param workingDir the working directory98 */99 static hardReset(branch, workingDir, quiet) {100 if (!branch) {101 console.warn('Hard reset operation skipped, must specify branch')102 } 103 else {104 return this._cmd(workingDir, `reset --hard ${branch}`, quiet)105 }106 }107 /**108 * Fetch latest changes from remote109 *110 * @param workingDir the working directory111 */112 static fetch(workingDir, quiet) {113 return this._cmd(workingDir, `fetch`, quiet)114 }115 /**116 * Pull down latest changes from remote117 *118 * @param workingDir the working directory119 */120 static pull(workingDir, quiet) {121 return this._cmd(workingDir, `pull`, quiet)122 }123 /**124 * Add file to commit125 *126 * @param workingDir the working directory127 * @param file file to add128 */129 static add(workingDir, file, quiet) {130 return this._cmd(workingDir, `add ${file}`, quiet)131 }132 /**133 * Create new commit134 *135 * @param workingDir the working directory136 * @param message commit message137 */138 static commit(workingDir, message, quiet) {139 return this._cmd(workingDir, `commit -s -m "${message}"`, quiet)140 }141 /**142 * Push committed changes to a remote repository143 *144 * @param branch the branch to be pushed to, required145 * @param dir the working directory, required146 */147 static push(branch, dir, username, passwd, repo, quiet) {148 if (!branch) {149 console.warn('Push operation skipped, must specify argument: branch')150 } 151 else {152 return this._cmd(dir, `push https://${username}:${passwd}@github.com/${repo} ${branch}`, quiet)153 }154 }155 /**156 * Check if current branch is synced with remote157 * 158 * @param branch the branch to be checked against, required159 * @param dir the working directory, required160 */161 static isSync(branch, dir) {162 // update remote163 utils.sh(`cd ${dir} && git fetch origin`)164 // get last hash165 var localHash = utils.sh(`cd ${dir} && git rev-parse ${branch}`)166 var remoteHash = utils.sh(`cd ${dir} && git rev-parse origin/${branch}`)167 if (localHash == remoteHash) {168 console.log('Working directory is synced with remote.')169 return true170 } else {171 console.warn(`Working directory is not synced with remote:172 local : ${localHash}173 remote: ${remoteHash}`)174 return false175 }176 }177 /**178 * Shallow clone a remote repository with latest179 *180 * @param dir the directory of where the this new branch checkouts to, required181 * @param branch the branch name to be newly made, required182 */183 static createOrphanBranch(dir, branch){184 if (!dir || !branch) {185 console.warn('createOrphanBranch operation skipped, must specify all three arguments: repo, dir and branch')186 }187 else {188 var cmd = `mkdir -p ${dir} && cd ${dir}`189 cmd += ` && git switch --orphan ${branch}`190 cmd += ' && git commit --allow-empty -m "Initial commit on orphan branch"'191 utils.sh(cmd)192 }193 }194}...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

1const child_process = require("child_process")2function getTerragruntCmd(params, settings, command){3 const runAll = params.runAll ? `run-all ` : ``4 const autoInit = settings.noAutoInit ? `--terragrunt-no-auto-init ` : ``;5 const autoRet = settings.noAutoRetry ? `--terragrunt-no-auto-init ` : ``;6 const opts = (params.options || ``).trim();7 const autoApprove = command !== 'init' ? `--auto-approve ` : ``;8 return `terragrunt ${runAll}${command} --terragrunt-non-interactive ${autoApprove}${autoInit}${autoRet}${opts}`;9}10async function runCLICommand(command, workingDir){11 return new Promise((resolve,reject) => {12 child_process.exec(command, {cwd: workingDir}, (error, stdout, stderr) => {13 if (error) {14 return reject(`exec error: ${error}`);15 }16 if (stderr) {17 console.log(`stderr: ${stderr}`);18 }19 return resolve(stdout);20 });21 })22}23async function execTerragruntInit(action, settings){24 const workingDir = action.params.workingDir;25 if (!workingDir){26 throw `No working directory specified`;27 }28 const cmd = getTerragruntCmd(action.params, settings, `init`);29 return runCLICommand(cmd, workingDir);30}31async function execTerragruntApply(action, settings){32 const workingDir = action.params.workingDir;33 if (!workingDir){34 throw `No working directory specified`;35 }36 const cmd = getTerragruntCmd(action.params, settings, `apply`);37 return runCLICommand(cmd, workingDir);38}39async function execTerragruntPlan(action, settings){40 const workingDir = action.params.workingDir;41 if (!workingDir){42 throw `No working directory specified`;43 }44 const cmd = getTerragruntCmd(action.params, settings, `plan`);45 return runCLICommand(cmd, workingDir);46}47async function execTerragruntDestroy(action, settings){48 const workingDir = action.params.workingDir;49 if (!workingDir){50 throw `No working directory specified`;51 }52 const cmd = getTerragruntCmd(action.params, settings, `destroy`);53 return runCLICommand(cmd, workingDir);54}55module.exports = {56 execTerragruntInit,57 execTerragruntPlan,58 execTerragruntApply,59 execTerragruntDestroy...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var parent = require('stryker-parent');2var workingDir = parent.workingDir();3console.log(workingDir);4var parent = require('stryker-parent');5var workingDir = parent.workingDir();6console.log(workingDir);7module.exports = function(config) {8 config.set({9 htmlReporter: {10 },11 mochaOptions: {12 }13 });14};15module.exports = function(config) {16 config.set({17 htmlReporter: {18 },19 mochaOptions: {20 }21 });22};23module.exports = function(config) {24 config.set({25 htmlReporter: {26 },27 mochaOptions: {28 }29 });30};31module.exports = function(config) {32 config.set({33 htmlReporter: {34 },35 mochaOptions: {36 }37 });38};39module.exports = function(config) {40 config.set({

Full Screen

Using AI Code Generation

copy

Full Screen

1var workingDir = require('stryker-parent').workingDir;2var path = require('path');3module.exports = function (config) {4 config.set({5 { pattern: path.join(workingDir(), 'src/**/*.js'), mutate: true },6 path.join(workingDir(), 'test/**/*.js')7 });8};9var workingDir = require('stryker-parent').workingDir;10var path = require('path');11module.exports = function (config) {12 config.set({13 { pattern: path.join(workingDir(), 'src/**/*.js'), mutate: true },14 path.join(workingDir(), 'test/**/*.js')15 });16};17var workingDir = require('stryker-parent').workingDir;18var path = require('path');19module.exports = function (config) {20 config.set({21 { pattern: path.join(workingDir(), 'src/**/*.js'), mutate: true },22 path.join(workingDir(), 'test/**/*.js')23 });24};25var workingDir = require('stryker-parent').workingDir;

Full Screen

Using AI Code Generation

copy

Full Screen

1console.log(require('stryker-parent').workingDir);2console.log(require('stryker-parent').workingDir);3module.exports = function(config) {4 config.set({5 { pattern: 'test.js', mutated: false, included: false }6 });7};8module.exports = function(config) {9 config.set({10 karmaConfig: {11 }12 });13};

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2const path = require('path');3console.log(strykerParent.workingDir(path.resolve(__dirname, './')));4module.exports = function(config) {5 config.set({6 { pattern: 'test.js', included: true, mutated: false }7 });8};919:03:09 (813) INFO JestTestRunner Using Jest CLI options: {"config":"D:\\stryker-js\\packages\\jest-runner\\testResources\\jest-config\\jest.config.js","maxWorkers":3,"runInBand":false}10 at Object.openSync (fs.js:443:3)11 at Object.readFileSync (fs.js:343:35)12 at Object.<anonymous> (test.js:2:35)1319:03:10 (813) ERROR InitialTestExecutor Initial test run failed. Stryker will exit prematurely. Error: ENOENT: no such file or directory, open 'D:\stryker-js\packages\jest-runner\testResources\jest-config\test.js'14 at Object.openSync (fs.js:443:3)15 at Object.readFileSync (fs.js:343:35)16 at Object.<anonymous> (test.js:2:35)1719:03:10 (813) INFO Stryker

Full Screen

Using AI Code Generation

copy

Full Screen

1var path = require('path');2var workingDir = require('stryker-parent/workingDir');3var workingDir = workingDir();4var testDir = path.join(workingDir, 'test');5console.log(testDir);6var path = require('path');7var workingDir = require('stryker-parent/workingDir');8var workingDir = workingDir();9var testDir = path.join(workingDir, 'test');10console.log(testDir);11var path = require('path');12var workingDir = require('stryker-parent/workingDir');13var workingDir = workingDir();14var testDir = path.join(workingDir, 'test');15console.log(testDir);16var path = require('path');17var workingDir = require('stryker-parent/workingDir');18var workingDir = workingDir();19var testDir = path.join(workingDir, 'test');20console.log(testDir);21var path = require('path');22var workingDir = require('stryker-parent/workingDir');23var workingDir = workingDir();24var testDir = path.join(workingDir, 'test');25console.log(testDir);26var path = require('path');27var workingDir = require('stryker-parent/workingDir');28var workingDir = workingDir();29var testDir = path.join(workingDir, 'test');30console.log(testDir);

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2var workingDir = strykerParent.workingDir();3console.log(workingDir);4workingDir()5get(configFile)6getTestResources()7getTestResources(pattern)8getTestResources(pattern, options)9var strykerParent = require('stryker-parent');10var testResourcesPath = strykerParent.getTestResources();11console.log(testResourcesPath);12var testResourcesPath = strykerParent.getTestResources('**/*.js');13console.log(testResourcesPath);14var testResourcesPath = strykerParent.getTestResources(['**/*.js', '**/*.css']);15console.log(testResourcesPath);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful