Best JavaScript code snippet using stryker-parent
file_input.js
Source:file_input.js
1/* ===========================================================2 * Bootstrap: inputfile.js v3.0.0-p73 * http://jasny.github.com/bootstrap/javascript.html#inputfile4 * ===========================================================5 * Copyright 2012 Jasny BV, Netherlands.6 *7 * Licensed under the Apache License, Version 2.0 (the "License")8 * you may not use this file except in compliance with the License.9 * You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing, software14 * distributed under the License is distributed on an "AS IS" BASIS,15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.16 * See the License for the specific language governing permissions and17 * limitations under the License.18 * ========================================================== */19+function ($) { "use strict";20 var isIE = window.navigator.appName == 'Microsoft Internet Explorer'21 // FILEUPLOAD PUBLIC CLASS DEFINITION22 // =================================23 var Fileupload = function (element, options) {24 this.$element = $(element)25 this.$input = this.$element.find(':file')26 if (this.$input.length === 0) return27 this.name = this.$input.attr('name') || options.name28 this.$hidden = this.$element.find('input[type=hidden][name="'+this.name+'"]')29 if (this.$hidden.length === 0) {30 this.$hidden = $('<input type="hidden" />')31 this.$element.prepend(this.$hidden)32 }33 this.$preview = this.$element.find('.inputfile-preview')34 var height = this.$preview.css('height')35 if (this.$preview.css('display') != 'inline' && height != '0px' && height != 'none') this.$preview.css('line-height', height)36 this.original = {37 exists: this.$element.hasClass('inputfile-exists'),38 preview: this.$preview.html(),39 hiddenVal: this.$hidden.val()40 }41 this.listen()42 }43 Fileupload.prototype.listen = function() {44 this.$input.on('change.bs.inputfile', $.proxy(this.change, this))45 $(this.$input[0].form).on('reset.bs.inputfile', $.proxy(this.reset, this))46 this.$element.find('[data-trigger="inputfile"]').on('click.bs.inputfile', $.proxy(this.trigger, this))47 this.$element.find('[data-dismiss="inputfile"]').on('click.bs.inputfile', $.proxy(this.clear, this))48 },49 Fileupload.prototype.change = function(e) {50 if (e.target.files === undefined) e.target.files = e.target && e.target.value ? [ {name: e.target.value.replace(/^.+\\/, '')} ] : []51 if (e.target.files.length === 0) return52 this.$hidden.val('')53 this.$hidden.attr('name', '')54 this.$input.attr('name', this.name)55 var file = e.target.files[0]56 if (this.$preview.length > 0 && (typeof file.type !== "undefined" ? file.type.match('image.*') : file.name.match(/\.(gif|png|jpe?g)$/i)) && typeof FileReader !== "undefined") {57 var reader = new FileReader()58 var preview = this.$preview59 var element = this.$element60 reader.onload = function(re) {61 var $img = $('<img>').attr('src', re.target.result).addClass('img-avatar img-avatar215 img-avatar-thumb');62 e.target.files[0].result = re.target.result63 element.find('.inputfile-filename').text(file.name)64 // if parent has max-height, using `(max-)height: 100%` on child doesn't take padding and border into account65 if (preview.css('max-height') != 'none') $img.css('max-height', parseInt(preview.css('max-height'), 10) - parseInt(preview.css('padding-top'), 10) - parseInt(preview.css('padding-bottom'), 10) - parseInt(preview.css('border-top'), 10) - parseInt(preview.css('border-bottom'), 10))66 preview.html($img)67 element.addClass('inputfile-exists').removeClass('inputfile-new')68 element.trigger('change.bs.inputfile', e.target.files)69 }70 reader.readAsDataURL(file)71 } else {72 this.$element.find('.inputfile-filename').text(file.name)73 this.$preview.text(file.name)74 this.$element.addClass('inputfile-exists').removeClass('inputfile-new')75 this.$element.trigger('change.bs.inputfile')76 }77 },78 Fileupload.prototype.clear = function(e) {79 if (e) e.preventDefault()80 this.$hidden.val('')81 this.$hidden.attr('name', this.name)82 this.$input.attr('name', '')83 //ie8+ doesn't support changing the value of input with type=file so clone instead84 if (isIE) {85 var inputClone = this.$input.clone(true);86 this.$input.after(inputClone);87 this.$input.remove();88 this.$input = inputClone;89 } else {90 this.$input.val('')91 }92 this.$preview.html('')93 this.$element.find('.inputfile-filename').text('')94 this.$element.addClass('inputfile-new').removeClass('inputfile-exists')95 if (e !== false) {96 this.$input.trigger('change')97 this.$element.trigger('clear.bs.inputfile')98 }99 },100 Fileupload.prototype.reset = function() {101 this.clear(false)102 this.$hidden.val(this.original.hiddenVal)103 this.$preview.html(this.original.preview)104 this.$element.find('.inputfile-filename').text('')105 if (this.original.exists) this.$element.addClass('inputfile-exists').removeClass('inputfile-new')106 else this.$element.addClass('inputfile-new').removeClass('inputfile-exists')107 this.$element.trigger('reset.bs.inputfile')108 },109 Fileupload.prototype.trigger = function(e) {110 this.$input.trigger('click')111 e.preventDefault()112 }113 // FILEUPLOAD PLUGIN DEFINITION114 // ===========================115 $.fn.inputfile = function (options) {116 return this.each(function () {117 var $this = $(this)118 , data = $this.data('inputfile')119 if (!data) $this.data('inputfile', (data = new Fileupload(this, options)))120 if (typeof options == 'string') data[options]()121 })122 }123 $.fn.inputfile.Constructor = Fileupload124 // FILEUPLOAD DATA-API125 // ==================126 $(document).on('click.inputfile.data-api', '[data-provides="inputfile"]', function (e) {127 var $this = $(this)128 if ($this.data('inputfile')) return129 $this.inputfile($this.data())130 var $target = $(e.target).closest('[data-dismiss="inputfile"],[data-trigger="inputfile"]');131 if ($target.length > 0) {132 e.preventDefault()133 $target.trigger('click.bs.inputfile')134 }135 })...
index.js
Source:index.js
1#!/usr/bin/env node2const argv = require('minimist')(process.argv.slice(2));3const path = require('path');4const exec = require('executive');5const fs = require('fs');6const action = argv._[0];7const inputFile = argv._[1];8const outputFile = argv._[2];9let scriptPath;10let cmd;11switch (action) {12 //Node Apps13 case 'area':14 require('./src/area')(inputFile);15 break;16 case 'bbox':17 require('./src/bbox')(inputFile);18 break;19 case 'bbox2fc':20 require('./src/bbox2fc')(argv.bbox);21 break;22 case 'buffer':23 require('./src/buffer')(inputFile, argv.unit, argv.radius, argv.prop);24 break;25 case 'fc2square':26 require('./src/fc2square')(inputFile, argv.radius);27 break;28 case 'clip':29 require('./src/clip')(inputFile, argv._[2]);30 break;31 case 'distance':32 require('./src/distance')(inputFile);33 break;34 case 'line2polygon':35 require('./src/line2polygon')(inputFile);36 break;37 case 'fc2frows':38 require('./src/fc2frows')(inputFile);39 break;40 case 'fc2csv':41 require('./src/fc2csv')(inputFile);42 break;43 case 'filterbyprop':44 require('./src/filterbyprop')(inputFile, argv.prop);45 break;46 case 'filterbygeometry':47 require('./src/filterbygeometry')(inputFile, argv.geos);48 break;49 case 'countfeature':50 require('./src/countfeature')(inputFile, argv.prop);51 break;52 case 'featurearea':53 require('./src/featurearea')(inputFile);54 break;55 case 'featurebbox':56 require('./src/featurebbox')(inputFile);57 break;58 case 'featuredistance':59 require('./src/featuredistance')(inputFile);60 break;61 case 'countbysize':62 require('./src/countbysize')(inputFile, argv.psize);63 break;64 case 'difference':65 require('./src/difference')(inputFile, argv._[2], argv.key);66 break;67 case 'duplicatefeatures':68 require('./src/duplicateFeatures')(inputFile, argv.key);69 break;70 case 'point2tile':71 require('./src/point2tile')(inputFile, argv.zoom, argv.buffer, argv.copyattrs);72 break;73 case 'tilecover':74 require('./src/tileCover')(inputFile, argv.zoom);75 break;76 case 'deletenulls':77 require('./src/deletenulls')(inputFile);78 break;79 case 'jsonlines2geojson':80 require('./src/jsonlines2geojson')(inputFile);81 break;82 case 'centroid':83 require('./src/centroid')(inputFile);84 break;85 case 'splitbyzoom':86 require('./src/splitbygrid')(inputFile, argv.folder, argv.zoom);87 break;88 case 'addattributefc':89 require('./src/addattributefc')(inputFile, argv.prop);90 break;91 case 'keepattributes':92 require('./src/keepattributes')(inputFile, argv.keys);93 break;94 case 'renamekey':95 require('./src/renamekey')(inputFile, argv.key);96 break;97 //Python scripts section98 case 'removeactionosm':99 scriptPath = path.join(__dirname, '/python-scripts/remove_acction_obj.py');100 cmd = ['python', scriptPath, inputFile, outputFile];101 exec(cmd.join(' '), outputFunction);102 break;103 case 'osm2new':104 scriptPath = path.join(__dirname, '/python-scripts/osm2new.py');105 cmd = ['python', scriptPath, inputFile, outputFile];106 exec(cmd.join(' '), outputFunction);107 break;108 case 'fixordinal':109 scriptPath = path.join(__dirname, '/python-scripts/fix_ordinal_suffixes.py');110 cmd = ['python', scriptPath, inputFile, outputFile];111 exec(cmd.join(' '), outputFunction);112 break;113 case 'cvat-count-tags':114 scriptPath = path.join(__dirname, '/python-scripts/cvat-count-tags.py');115 cmd = ['python', scriptPath, inputFile, outputFile];116 exec(cmd.join(' '), outputFunction);117 break;118 case 'cvat-xml2csv':119 scriptPath = path.join(__dirname, '/python-scripts/cvat-xml2csv.py');120 cmd = ['python', scriptPath, argv.full ? '--full' : '', inputFile];121 exec(cmd.join(' '), outputFunction);122 break;123 case 'downsized-imgs':124 scriptPath = path.join(__dirname, '/python-scripts/downsized-imgs.py');125 cmd = ['python', scriptPath, inputFile];126 exec(cmd.join(' '), outputFunction);127 break;128 case 'cvat-npz2xml':129 scriptPath = path.join(__dirname, '/python-scripts/cvat-npz2xml.py');130 cmd = ['python', scriptPath, inputFile, argv.imgPath, argv.imgLabel];131 exec(cmd.join(' '), outputFunction);132 break;133 case 'cvat-xml2npz':134 scriptPath = path.join(__dirname, '/python-scripts/cvat-xml2npz.py');135 cmd = ['python', scriptPath, inputFile];136 exec(cmd.join(' '), outputFunction);137 break;138 //help139 case 'help':140 case '--help':141 default:142 console.log(fs.readFileSync(path.join(__dirname, '/cli.txt'), 'UTF-8'));143}144function outputFunction(error, stdout, stderr) {145 if (error) console.log(error);146 // console.log(stdout);...
file-utils.js
Source:file-utils.js
1const colors = Npm.require('colors');2export function isBare(inputFile) {3 const fileOptions = inputFile.getFileOptions();4 return fileOptions && fileOptions.bare;5}6// Gets root app tsconfig.7export function isMainConfig(inputFile) {8 if (! isWeb(inputFile)) return false;9 const filePath = inputFile.getPathInPackage();10 return /^tsconfig\.json$/.test(filePath);11}12export function isConfig(inputFile) {13 const filePath = inputFile.getPathInPackage();14 return /tsconfig\.json$/.test(filePath);15}16// Gets server tsconfig.17export function isServerConfig(inputFile) {18 if (isWeb(inputFile)) return false;19 const filePath = inputFile.getPathInPackage();20 return /^server\/tsconfig\.json$/.test(filePath);21}22// Checks if it's .d.ts-file.23export function isDeclaration(inputFile) {24 return TypeScript.isDeclarationFile(inputFile.getBasename());25}26export function isWeb(inputFile) {27 const arch = inputFile.getArch();28 return /^web/.test(arch);29}30// Gets path with package prefix if any.31export function getExtendedPath(inputFile) {32 let packageName = inputFile.getPackageName();33 packageName = packageName ?34 (packageName.replace(':', '_') + '/') : '';35 const inputFilePath = inputFile.getPathInPackage();36 return packageName + inputFilePath;37}38export function getES6ModuleName(inputFile) {39 const extended = getExtendedPath(inputFile);40 return TypeScript.removeTsExt(extended);41}42export const WarnMixin = {43 warn(error) {44 console.log(`${error.sourcePath} (${error.line}, ${error.column}): ${error.message}`);45 },46 logError(error) {47 console.log(colors.red(48 `${error.sourcePath} (${error.line}, ${error.column}): ${error.message}`));49 }50}51export function extendFiles(inputFiles, fileMixin) {52 inputFiles.forEach(inputFile => _.defaults(inputFile, fileMixin));...
Using AI Code Generation
1var inputFile = require('stryker-parent').inputFile;2inputFile('test.js');3var outputFile = require('stryker-parent').outputFile;4outputFile('test.js');5var inputDir = require('stryker-parent').inputDir;6inputDir('test.js');7var outputDir = require('stryker-parent').outputDir;8outputDir('test.js');9var inputFile = require('stryker-parent').inputFile;10inputFile('test.js');11var outputFile = require('stryker-parent').outputFile;12outputFile('test.js');13var inputDir = require('stryker-parent').inputDir;14inputDir('test.js');15var outputDir = require('stryker-parent').outputDir;16outputDir('test.js');17var inputFile = require('stryker-parent').inputFile;18inputFile('test.js');19var outputFile = require('stryker-parent').outputFile;20outputFile('test.js');21var inputDir = require('stryker-parent').inputDir;22inputDir('test.js');23var outputDir = require('stryker-parent').outputDir;24outputDir('test.js');25var inputFile = require('stryker-parent').inputFile;26inputFile('test.js');27var outputFile = require('stryker-parent').outputFile;28outputFile('test.js');29var inputDir = require('stryker-parent').inputDir;30inputDir('test.js');31var outputDir = require('stryker-parent').outputDir;32outputDir('
Using AI Code Generation
1var inputFile = require('stryker-parent').inputFile;2var content = inputFile('test.txt');3console.log(content);4module.exports = function(config) {5 config.set({6 });7};
Using AI Code Generation
1const inputFile = require('stryker-parent').inputFile;2const path = require('path');3module.exports = function(config) {4 config.set({5 inputFile(path.join(__dirname, 'test.txt'))6 });7}8const assert = require('assert');9const inputFile = require('stryker-parent').inputFile;10const path = require('path');11describe('inputFile', () => {12 it('should return the file content', () => {13 assert.equal(inputFile(path.join(__dirname, 'test.txt')), 'Hello World!');14 });15});16const assert = require('assert');17const inputFiles = require('stryker-parent').inputFiles;18const path = require('path');19describe('inputFiles', () => {20 it('should return the file content', () => {21 const files = inputFiles(path.join(__dirname, 'test.txt'), path.join(__dirname, 'test2.txt'));22 assert.equal(files[0].name, 'test.txt');23 assert.equal(files[0].content, 'Hello World!');24 assert.equal(files[1].name, 'test2.txt');25 assert.equal(files[1].content, 'Hello World 2!');26 });27});28const assert = require('assert');29const outputFile = require('stryker-parent').outputFile;30const path = require('path');31describe('outputFile', () => {32 it('should return the file content', () => {33 assert.equal(outputFile(path.join(__dirname, 'test.txt')), 'Hello World!');34 });35});36const assert = require('assert');37const outputFiles = require('stryker-parent').output
Using AI Code Generation
1var inputFile = require('stryker-parent').inputFile;2var file = inputFile('test.txt');3var outputFile = require('stryker-parent').outputFile;4outputFile('test.txt', 'Hello World');5var deleteFile = require('stryker-parent').deleteFile;6deleteFile('test.txt');7var copyFile = require('stryker-parent').copyFile;8copyFile('test.txt', 'test2.txt');9var copyFile = require('stryker-parent').copyFile;10copyFile('test.txt', 'test2.txt');11var moveFile = require('stryker-parent').moveFile;12moveFile('test.txt', 'test2.txt');13var existsFile = require('stryker-parent').existsFile;14var exists = existsFile('test.txt');15var listFiles = require('stryker-parent').listFiles;16var files = listFiles('test');17var listFilesRecursively = require('stryker-parent').listFilesRecursively;18var files = listFilesRecursively('test');
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!