Best JavaScript code snippet using backstopjs
scanner.js
Source:scanner.js
1/**2 * @type replace : A simple utility to quickly replace text in one or more files or globs.3 * @type path : The path module provides utilities for working with file and directory paths.4 * @type del : Delete files and directories using globs5 */6const replace = require( 'replace-in-file' );7const path = require( 'path' );8const { existsSync, writeFileSync, readFile, mkdirSync }9 = require( 'fs' );10const fs = require( 'fs-extra' );11const { promisify }12 = require( 'util' );13const del = require( 'del' );14/**15 * The scanner class16 */17class Scanner {18 /**19 * Gets the full path of where the20 * project is being created21 * @returns {string}22 */23 getFullPath() {24 return path.join( process.cwd() );25 }26 /**27 * Replacer28 * @param pathToFolder - folder to search in29 * @param files - files to replace30 * @param from - target to replace31 * @param to - the replacement32 * @returns {Promise<*>}33 */34 async replacer( files, from, to, pathToFolder ) {35 return replace( {36 files: files,37 from: from,38 to: to,39 ignore: [40 path.join( `${ pathToFolder }/node_modules/**/*` ),41 path.join( `${ pathToFolder }/vendor/**/*` ),42 path.join( `${ pathToFolder }/packages/**/*` ),43 ],44 } )45 }46 /**47 * Removes folder48 * @param folder49 * @returns {Promise<void>}50 */51 async removeFolder( folder ) {52 try {53 await fs.remove( folder )54 } catch ( err ) {55 console.error( err )56 }57 }58 /**59 * https://github.com/adamreisnz/replace-in-file60 * @param data61 * @param projectPath62 * @returns {Promise<void>}63 */64 async searchReplace( data, projectPath ) {65 const phpFiles = [66 path.join( projectPath, 'the-plugin-name.php' ),67 path.join( projectPath, 'src', 'bootstrap.php' ),68 path.join( projectPath, 'src', 'App', '**', '*.php' ),69 path.join( projectPath, 'src', 'Common', '**', '*.php' ),70 path.join( projectPath, 'src', 'Compatibility', '**', '*.php' ),71 path.join( projectPath, 'src', 'Config', '**', '*.php' ),72 path.join( projectPath, 'src', 'Integrations', '**', '*.php' ),73 path.join( projectPath, 'templates', '*.php' ),74 path.join( projectPath, 'languages', 'the-plugin-name-text-domain.pot' )75 ];76 const codeceptionFiles = [77 path.join( projectPath, 'tests', 'wpunit.suite.yml' ),78 path.join( projectPath, '.env.testing' ),79 path.join( projectPath, 'codeception.dist.yml' ),80 ];81 const codesnifferFiles = [82 path.join( projectPath, 'phpcs.xml.dist' ),83 ];84 const travisCiFiles = [85 path.join( projectPath, '.travis.yml' ),86 ];87 const bootstrapFile = path.join( projectPath, 'src', 'bootstrap.php' );88 const composerFile = path.join( projectPath, 'composer.json' );89 const pathEntryFile = path.join( projectPath, `the-plugin-name.php` );90 // PHP Files91 if ( data.projectName && data.description && data.url && data.package &&92 data.author && data.authorEmail && data.license ) {93 /**94 * All occurrences95 */96 await this.replacer( // Plugin name used in file meta, translation functions etc.97 phpFiles, /{{The Plugin Name}}/g, `${ data.projectName }`, projectPath98 );99 await this.replacer( // Plugin description used in main file meta as "Description" for example100 phpFiles, /{{plugin_description}}/g, `${ data.description }`, projectPath101 );102 await this.replacer( // Plugin url used in main file meta as "Plugin URI" for example103 phpFiles, /{{plugin_url}}/g, `https://${ data.url }`, projectPath104 );105 await this.replacer( // Package name used in PHP doc @package for example106 phpFiles, /{{the-plugin-name}}/g, `${ data.package }`, projectPath107 );108 await this.replacer( // Package name used in the webpack package.json in the translate script109 phpFiles, /{{the-project-name}}/g, `${ data.package }`, projectPath110 );111 await this.replacer( // Plugin author used in PHP doc @author for example112 phpFiles, /{{author_name}}/g, `${ data.author }`, projectPath113 );114 await this.replacer( // Plugin author used in PHP doc @author for example115 phpFiles, /{{version}}/g, `${ data.pluginVersion }`, projectPath116 );117 await this.replacer( // Plugin author email used in PHP doc @author for example118 phpFiles, /{{author_email}}/g, `${ data.authorEmail }`, projectPath119 );120 await this.replacer( // Plugin author link used in PHP doc @link for example121 phpFiles, /{{author_url}}/g, `https://${ data.url }`, projectPath122 );123 await this.replacer( // Plugin copyright used in PHP doc @copyright for example124 phpFiles, /{{author_copyright}}/g, `${ new Date().getFullYear() } ${ data.projectName }`, projectPath125 );126 await this.replacer( // Plugin license used in PHP doc @licence for example127 phpFiles, /{{author_license}}/g, `${ data.license }`, projectPath128 );129 /**130 * Meta131 */132 await this.replacer( // PHP plugin meta text domain in "the-plugin-name.php"133 phpFiles,134 /^ \* Text Domain:.*$/m, ` * Text Domain: ${ data.package }`, projectPath135 );136 await this.replacer( // PHP plugin meta text namespace in "the-plugin-name.php"137 phpFiles,138 /^ \* Namespace:.*$/m, ` * Namespace: ${ data.namespace }`, projectPath139 );140 /**141 * Translation functions142 */143 await this.replacer( // text domain in translation functions144 phpFiles, /the-plugin-name-text-domain/g, `${ data.package }`, projectPath145 );146 /**147 * Namespace148 */149 await this.replacer( // File namespace150 phpFiles, /namespace ThePluginName/g, `${ 'namespace ' + data.namespace }`, projectPath151 );152 await this.replacer( // Namespace called in various occurrences153 phpFiles, /ThePluginName\\/g, `${ data.namespace + '\\' }`, projectPath154 );155 /**156 * Functions, constants, variables157 */158 await this.replacer( // Constants with prefixes159 phpFiles, /_THE_PLUGIN_NAME_/g, `${ data.prefix + '_' }`, projectPath160 );161 await this.replacer( // File or global variables with prefixes162 phpFiles, /\$the_plugin_name_/g, `${ '$' + data.lowerCasePrefix + '_' }`, projectPath163 );164 await this.replacer( // Plugin database settings variable in src/Config/Plugin.php165 phpFiles, /get_option\( 'the-plugin-name-/g, `${ 'get_option( \'' + data.package + '-' }`, projectPath166 );167 await this.replacer( // external template folder name in src/Config/Plugin.php168 phpFiles, /=> 'the-plugin-name-templates/g, `${ '=> \'' + data.package + '-templates' }`, projectPath169 );170 await this.replacer( // External function (only in the-plugin-name.php)171 phpFiles, /the_plugin_name\(\)/g, `${ data.lowerCasePrefix + '()' }`, projectPath172 );173 /**174 * Filters & actions175 */176 await this.replacer( // Filters177 phpFiles, /apply_filters\( 'the_plugin_name_/g, `${ 'apply_filters( \'' + data.lowerCasePrefix + '_' }`, projectPath178 );179 await this.replacer( // Actions180 phpFiles, /do_action\( 'the_plugin_name_/g, `${ 'do_action( \'' + data.lowerCasePrefix + '_' }`, projectPath181 );182 }183 /**184 * Codeception185 */186 if ( data.codeception === 'yes' ) {187 await this.replacer(188 codeceptionFiles, /the-plugin-name\/the-plugin-name.php/g, `${ data.package + '/' + data.package }.php`, projectPath189 );190 } else {191 // delete files and folders if not needed192 await del( codeceptionFiles );193 await del( projectPath + '/tests' );194 }195 /**196 * PHPCodeSniffer ~ PHPCS197 */198 if ( data.codesniffer === 'yes' ) {199 await this.replacer(200 codesnifferFiles, /<ruleset name="The Plugin Name ruleset">/g, `<ruleset name="${ data.projectName } ruleset">`, projectPath201 );202 await this.replacer(203 codesnifferFiles, /<description>Ruleset for the The Plugin Name.<\/description>/g, `<description>Ruleset for the ${ data.projectName }.</description>`, projectPath204 );205 await this.replacer(206 codesnifferFiles, /<element value="ThePluginName"\/>/g, `<element value="${ data.namespace }"/>`, projectPath207 );208 await this.replacer(209 codesnifferFiles, /<element value="_THE_PLUGIN_NAME"\/>/g, `<element value="${ data.prefix }"/>`, projectPath210 );211 await this.replacer(212 codesnifferFiles, /<element value="the_plugin_name"\/>/g, `<element value="${ data.lowerCasePrefix }"/>`, projectPath213 );214 await this.replacer(215 codesnifferFiles, /<file>the-plugin-name.php<\/file>/g, `<file>${ data.package }.php</file>`, projectPath216 );217 await this.replacer(218 codesnifferFiles, /<element value="the-plugin-name-text-domain"\/>/g, `<element value="${ data.package }"/>`, projectPath219 );220 } else {221 // delete files and folders if not needed222 await del( codesnifferFiles );223 if ( data.travisCi === 'yes' ) {224 await this.replacer(225 travisCiFiles, [226 / - composer phpcs/g,227 / # Run PHPCS\./g228 ], ``, projectPath229 );230 }231 }232 if ( data.travisCi === 'no' ) {233 await del( travisCiFiles );234 }235 /**236 * Composer.json237 */238 await this.replacer(239 composerFile, /ThePluginName\\/g, `${ data.namespace }\\`, projectPath240 );241 /**242 * Modify composer.json dependencies based on prior conditions243 */244 const readComposer = promisify( readFile );245 const composerData = JSON.parse( await readComposer( composerFile, 'utf-8' ) );246 if ( data.codesniffer === 'no' ) {247 delete composerData[ 'require-dev' ][ 'dealerdirect/phpcodesniffer-composer-installer' ];248 delete composerData[ 'require-dev' ][ 'wp-coding-standards/wpcs' ];249 delete composerData[ 'require-dev' ][ 'automattic/phpcs-neutron-ruleset' ];250 delete composerData[ 'require-dev' ][ 'phpcompatibility/phpcompatibility-wp' ];251 delete composerData[ 'scripts' ][ 'phpcs' ];252 }253 if ( data.codeception === 'no' ) {254 delete composerData[ 'require-dev' ][ 'lucatume/function-mocker' ];255 delete composerData[ 'require-dev' ][ 'lucatume/wp-browser' ];256 delete composerData[ 'require-dev' ][ 'codeception/lib-innerbrowser' ];257 delete composerData[ 'require-dev' ][ 'codeception/module-asserts' ];258 delete composerData[ 'require-dev' ][ 'codeception/module-phpbrowser' ];259 delete composerData[ 'require-dev' ][ 'codeception/module-webdriver' ];260 delete composerData[ 'require-dev' ][ 'codeception/module-db' ];261 delete composerData[ 'require-dev' ][ 'codeception/module-filesystem' ];262 delete composerData[ 'require-dev' ][ 'codeception/module-cli' ];263 delete composerData[ 'require-dev' ][ 'codeception/module-rest' ];264 delete composerData[ 'require-dev' ][ 'codeception/util-universalframework' ];265 delete composerData[ 'require-dev' ][ 'codeception/codeception-progress-reporter' ];266 delete composerData[ 'scripts' ][ 'codecept' ];267 delete composerData[ 'scripts' ][ 'run:wpunit' ];268 delete composerData[ 'scripts' ][ 'run:functional' ];269 delete composerData[ 'scripts' ][ 'run:acceptance' ];270 delete composerData[ 'scripts' ][ 'generate:wpunit' ];271 delete composerData[ 'scripts' ][ 'generate:functional' ];272 delete composerData[ 'scripts' ][ 'generate:acceptance' ];273 }274 writeFileSync( composerFile, JSON.stringify( composerData, null, 4 ) );275 /**276 * Rename the plugin entry file277 */278 if ( await fs.pathExists( pathEntryFile ) ) {279 fs.rename( pathEntryFile, path.join( projectPath, `${ data.package }.php` ) );280 }281 /**282 * If webpack is included then move them to the right spot283 */284 if ( data.webpack === 'yes' ) {285 const packageJsonFile = path.join( projectPath, 'package.json' );286 await fs.move( projectPath + '/wordpress-webpack-workflow/assets/src', projectPath + '/assets/src' );287 await fs.move( projectPath + '/wordpress-webpack-workflow/webpack', projectPath + '/webpack' );288 await fs.move( projectPath + '/wordpress-webpack-workflow/package.json', projectPath + '/package.json' );289 await fs.move( projectPath + '/wordpress-webpack-workflow/webpack.config.js', projectPath + '/webpack.config.js' );290 await this.removeFolder( projectPath + '/wordpress-webpack-workflow/' );291 /**292 * Package.json293 */294 await this.replacer( // translation --dest-file295 packageJsonFile, /languages\/wordpress-webpack.pot/g, `languages/${ data.package }.pot`, projectPath296 );297 await this.replacer( // translation --package298 packageJsonFile, /--package '{{the-project-name}}'/g, `--package '${ data.package }'`, projectPath299 );300 await this.replacer( // translation --domain301 packageJsonFile, /--domain '{{the-project-text-domain}}'/g, `--domain '${ data.package }'`, projectPath302 );303 await this.replacer( // translation --last-translator304 packageJsonFile, /--last-translator '{{author_name}} <{{author_email}}>'/g, `--last-translator '${ data.author } <${ data.authorEmail }>'`, projectPath305 );306 await this.replacer( // translation --team307 packageJsonFile, /--team '{{author_name}} <{{author_email}}>'/g, `--team '${ data.author } <${ data.authorEmail }>'`, projectPath308 );309 await this.replacer( // translation --bug-report310 packageJsonFile, /--bug-report '{{author_url}}'/g, `--bug-report '${ data.url }'`, projectPath311 );312 }313 const TranslationFile = path.join( projectPath, 'languages', 'the-plugin-name-text-domain.pot' );314 /**315 * Change translation file316 */317 await this.replacer(318 TranslationFile, /the-plugin-name.php/g, `${ data.package }.php`, projectPath319 );320 /**321 * Rename the translation file322 */323 if ( await fs.pathExists( TranslationFile ) ) {324 fs.rename( TranslationFile, path.join( projectPath, 'languages', `${ data.package }.pot` ) );325 }326 }327 /**328 * https://github.com/adamreisnz/replace-in-file329 * @param data330 * @param projectPath331 * @returns {Promise<void>}332 */333 async searchReplaceWebPack( data, projectPath ) {334 const webpackConfig = path.join( projectPath, '/wordpress-webpack-workflow/webpack.config.js' );335 const jsFiles = path.join( projectPath, '/wordpress-webpack-workflow/assets', 'src', 'js', '**', '*.js' );336 /**337 * Change CSS type338 */339 if ( data.css === 'PostCSS-only' ) {340 await this.replacer( // Change sass to postcss in webpack config341 webpackConfig, /use: 'sass', \/\/ sass \|\| postcss/g, `use: 'postcss', // sass || postcss`, projectPath342 );343 await this.replacer( // Change CSS src folder344 jsFiles, /\/sass\//g, `/postcss/`, projectPath345 );346 await this.replacer( // Change CSS file ext347 jsFiles, /.scss/g, `.pcss`, projectPath348 );349 }350 }351}...
gulpfile.js
Source:gulpfile.js
1'use strict';2/************/3/* Settings */4/************/5/* Gulp plugins */6var gulp = require('gulp'), // Task runner7 watch = require('gulp-watch'), // Watch, that actually is an endless stream8 rename = require("gulp-rename"), // Rename files9 del = require('del'), // Delete something10 rigger = require('gulp-rigger'), // // Include content of one file to another11 size = require('gulp-size'), // Display the size of something12 path = require('path'),13 processhtml = require('gulp-processhtml'), // Plugin uses Denis Ciccale's node-htmlprocessor to process/transform html files14 concat = require('gulp-concat'), // Concatenates files15 streamqueue = require('streamqueue'), // Pipe queued streams progressively, keeping datas order.16 sourcemaps = require('gulp-sourcemaps'), // Write source maps17 less = require('gulp-less'), // Compile Less to CSS18 lessReporter = require('gulp-less-reporter'), // Error reporter for gulp-less19 autoprefixer = require('gulp-autoprefixer'), // Prefix CSS20 csscomb = require('gulp-csscomb'), // Coding style formatter for CSS21 minifycss = require('gulp-minify-css'), // Minify CSS22 uglify = require('gulp-uglify'), // Minify JS23 jshint = require('gulp-jshint'), // JS code linter24 stylish = require('jshint-stylish'), // Reporter for JSHint25 imagemin = require('gulp-imagemin'), // Optimize images26 pngquant = require('imagemin-pngquant'), // PNG plugin for ImageMin27 spritesmith = require('gulp.spritesmith'), // Convert a set of images into a spritesheet and CSS variables28 svg2png = require('gulp-svg2png'), // Convert SVGs to PNGs29 svgmin = require('gulp-svgmin'), // Minify SVG with SVGO30 svgspritesheet = require('gulp-svg-spritesheet'), // Convert a set of SVGs into a spritesheet and CSS variables31 browserSync = require("browser-sync"), // Synchronised browser testing32 reload = browserSync.reload,33 ghPages = require('gulp-gh-pages'), // Publish contents to Github pages34 runSequence = require('run-sequence').use(gulp); // Run a series of dependent gulp tasks in order35/* Path settings */36var projectPath = {37 build: { // Set build paths38 html: 'build/',39 js: 'build/js/',40 jsMainFile: 'main.js',41 css: 'build/css/',42 img: 'build/img/images/',43 svg: 'build/img/svg/',44 pngSprite: 'build/img/sprites/png/',45 pngSpriteCSS: 'src/styles/common/',46 svgSprite: 'build/img/sprites/svg/svg-sprite.svg',47 svgSpriteNoSvg: 'build/img/sprites/svg/svg-sprite.png',48 svgSpriteCSS: 'src/styles/common/_svg-sprite.less',49 fonts: 'build/css/fonts/',50 files: 'build/files/'51 },52 src: { // Set source paths53 html: ['src/**/*.html', 'humans.txt'],54 jsCustom: 'src/js/custom.js',55 jsVendor: 'src/js/vendor.js',56 style: 'src/styles/style.less',57 img: 'src/img/images/**/*.*',58 svg: 'src/img/svg/**/*.svg',59 pngSprite: 'src/img/sprites/png/**/*.png',60 pngRetinaSprite: 'src/img/sprites/png/**/*-2x.png',61 svgSprite: 'src/img/sprites/svg/**/*.svg',62 svgSpriteTpl: 'src/styles/common/_svg-sprite-less.tpl',63 fonts: 'src/styles/fonts/**/*.*',64 files: 'src/files/**/*.*'65 },66 watch: { // Set watch paths67 html: 'src/**/*.html',68 js: 'src/js/**/*.js',69 style: 'src/styles/**/*.less',70 img: 'src/img/images/**/*.*',71 svg: 'src/img/svg/**/*.svg',72 pngSprite: 'src/img/sprites/png/**/*.png',73 svgSprite: 'src/img/sprites/svg/**/*.svg',74 fonts: 'src/styles/fonts/**/*.*'75 },76 clean: ['build/**/*', '!build/.gitignore', '!build/humans.txt'], // Set paths and exludes for cleaning build dir77 ghPages: 'build/**/*' // Set dir that will be uploaded to GitHub Pages78};79/* BrowserSync local web server settings */80var config = {81 server: {82 baseDir: "./build"83 },84 tunnel: true,85 host: 'localhost',86 port: 9000,87 injectChanges: true,88 logPrefix: "App Front-End"89};90/*********/91/* Tasks */92/*********/93/* BrowserSync local web server*/94gulp.task('webserver', function () {95 browserSync(config);96});97/* HTML */98gulp.task('html', function () {99 return gulp.src(projectPath.src.html)100 .pipe(processhtml({101 recursive: true102 }))103 .pipe(size({104 title: 'HTML'105 }))106 .pipe(gulp.dest(projectPath.build.html))107 .pipe(reload({stream: true}));108});109/* JavaScript */110gulp.task('js', function () {111 return streamqueue(112 { objectMode: true },113 gulp.src(projectPath.src.jsVendor).pipe(rigger()).pipe(size({title: 'Vendor JavaScript'})),114 gulp.src(projectPath.src.jsCustom).pipe(rigger()).pipe(jshint()).pipe(jshint.reporter(stylish)).pipe(size({title: 'Custom JavaScript'}))115 )116 .pipe(concat(projectPath.build.jsMainFile))117 .pipe(sourcemaps.init())118 .pipe(gulp.dest(projectPath.build.js))119 .pipe(rename({ suffix: '.min' }))120 .pipe(uglify())121 .pipe(sourcemaps.write('./'))122 .pipe(size({123 title: 'Total JavaScript'124 }))125 .pipe(gulp.dest(projectPath.build.js))126 .pipe(reload({stream: true}));127});128/* Less */129gulp.task('less', function() {130 return gulp.src(projectPath.src.style)131 .pipe(sourcemaps.init())132 .pipe(less({133 paths: [ path.join(__dirname, 'less', 'includes') ]134 }))135 .on('error', lessReporter)136 .pipe(autoprefixer('> 2%'))137 .pipe(csscomb())138 .pipe(gulp.dest(projectPath.build.css))139 .pipe(rename({ suffix: '.min' }))140 .pipe(minifycss())141 .pipe(sourcemaps.write('./'))142 .pipe(size({143 title: 'CSS'144 }))145 .pipe(gulp.dest(projectPath.build.css))146 .pipe(reload({stream: true}));147});148/* Images */149gulp.task('images', function () {150 return gulp.src(projectPath.src.img)151 .pipe(imagemin({152 progressive: true,153 optimizationLevel: 5,154 use: [pngquant()],155 interlaced: true156 }))157 .pipe(size({158 title: 'Images'159 }))160 .pipe(gulp.dest(projectPath.build.img))161 .pipe(reload({stream: true}));162});163/* SVG */164gulp.task('svg', function () {165 return gulp.src(projectPath.src.svg)166 .pipe(svgmin())167 .pipe(size({168 title: 'SVG'169 }))170 .pipe(gulp.dest(projectPath.build.svg))171 .pipe(reload({stream: true}));172});173/* PNG Sprite */174gulp.task('png-sprite', function () {175 // Generate spritesheet176 var spriteData = gulp.src(projectPath.src.pngSprite).pipe(spritesmith({177 imgName: 'png-sprite.png',178 imgPath: '../img/sprites/png/png-sprite.png',179 //retinaSrcFilter: projectPath.src.pngRetinaSprite,180 //retinaImgName: 'png-sprite-2x.png',181 //retinaImgPath: '../img/sprites/png/png-sprite-2x.png',182 padding: 0,183 cssName: '_png-sprite.less',184 cssVarMap: function (sprite) {185 sprite.name = 'sprite__' + sprite.name;186 }187 }));188 // Pipe image stream through image optimizer and onto disk189 spriteData.img190 .pipe(imagemin())191 .pipe(gulp.dest(projectPath.build.pngSprite));192 // Pipe CSS stream onto disk193 spriteData.css194 .pipe(gulp.dest(projectPath.build.pngSpriteCSS))195 .pipe(reload({stream:true}));196});197/* SVG sprite */198gulp.task('svg-sprite', function () {199 gulp.src(projectPath.src.svgSprite)200 .pipe(svgspritesheet({201 cssPathNoSvg: '../img/sprites/svg/svg-sprite.png',202 cssPathSvg: '../img/sprites/svg/svg-sprite.svg',203 padding: 0,204 pixelBase: 16,205 positioning: 'packed',206 templateSrc: projectPath.src.svgSpriteTpl,207 templateDest: projectPath.build.svgSpriteCSS,208 units: 'px'209 }))210 .pipe(svgmin())211 .pipe(gulp.dest(projectPath.build.svgSprite))212 .pipe(svg2png())213 .pipe(gulp.dest(projectPath.build.svgSpriteNoSvg));214});215/* Fonts */216gulp.task('fonts', function() {217 return gulp.src(projectPath.src.fonts)218 .pipe(size({219 title: 'Fonts'220 }))221 .pipe(gulp.dest(projectPath.build.fonts))222 .pipe(reload({stream: true}));223});224/* Files */225gulp.task('files', function() {226 return gulp.src(projectPath.src.files)227 .pipe(size({228 title: 'Files'229 }))230 .pipe(gulp.dest(projectPath.build.files))231 .pipe(reload({stream: true}));232});233/* Clean build directory */234gulp.task('clean', function (cb) {235 del(projectPath.clean, cb);236});237/* Build */238gulp.task('build', function(callback) {239 runSequence(240 'clean',241 'html',242 'js',243 'less',244 'images',245 'png-sprite',246 'svg-sprite',247 'svg',248 'fonts',249 'files',250 'gh-pages',251 callback)252});253/* Github Pages */254gulp.task('gh-pages', function() {255 return gulp.src(projectPath.ghPages)256 .pipe(ghPages());257});258/* Watching */259gulp.task('watch',['webserver'], function(){260 watch([projectPath.watch.html], function(event, cb) {261 gulp.start('html');262 });263 watch([projectPath.watch.js], function(event, cb) {264 gulp.start('js');265 });266 watch([projectPath.watch.style], function(event, cb) {267 gulp.start('less');268 });269 watch([projectPath.watch.img], function(event, cb) {270 gulp.start('images');271 });272 watch([projectPath.watch.svg], function(event, cb) {273 gulp.start('svg');274 });275 watch([projectPath.watch.pngSprite], function(event, cb) {276 gulp.start('png-sprite');277 });278 watch([projectPath.watch.svgSprite], function(event, cb) {279 gulp.start('svg-sprite');280 });281 watch([projectPath.watch.fonts], function(event, cb) {282 gulp.start('fonts');283 });284});285/* Default */286gulp.task('default', ['watch'], function() {...
main.js
Source:main.js
1'use strict';2var _asyncToGenerator = _interopRequireDefault(require('async-to-generator'));3var _atom = require('atom');4var _nuclideBusySignal;5function _load_nuclideBusySignal() {6 return _nuclideBusySignal = require('../../nuclide-busy-signal');7}8var _createPackage;9function _load_createPackage() {10 return _createPackage = _interopRequireDefault(require('../../commons-atom/createPackage'));11}12var _scheduleIdleCallback;13function _load_scheduleIdleCallback() {14 return _scheduleIdleCallback = _interopRequireDefault(require('../../commons-node/scheduleIdleCallback'));15}16var _nuclideRemoteConnection;17function _load_nuclideRemoteConnection() {18 return _nuclideRemoteConnection = require('../../nuclide-remote-connection');19}20var _nuclideRpc;21function _load_nuclideRpc() {22 return _nuclideRpc = require('../../nuclide-rpc');23}24var _nuclideLogging;25function _load_nuclideLogging() {26 return _nuclideLogging = require('../../nuclide-logging');27}28var _FuzzyFileNameProvider;29function _load_FuzzyFileNameProvider() {30 return _FuzzyFileNameProvider = _interopRequireDefault(require('./FuzzyFileNameProvider'));31}32var _utils;33function _load_utils() {34 return _utils = require('./utils');35}36function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }37// eslint-disable-next-line nuclide-internal/no-cross-atom-imports38const logger = (0, (_nuclideLogging || _load_nuclideLogging()).getLogger)(); /**39 * Copyright (c) 2015-present, Facebook, Inc.40 * All rights reserved.41 *42 * This source code is licensed under the license found in the LICENSE file in43 * the root directory of this source tree.44 *45 * 46 */47class Activation {48 constructor() {49 this._busySignalProvider = new (_nuclideBusySignal || _load_nuclideBusySignal()).BusySignalProviderBase();50 this._subscriptions = new _atom.CompositeDisposable();51 this._subscriptionsByRoot = new Map();52 this._readySearch = this._readySearch.bind(this);53 // Do search preprocessing for all existing and future root directories.54 this._readySearch(atom.project.getPaths());55 this._subscriptions.add(atom.project.onDidChangePaths(this._readySearch));56 }57 _readySearch(projectPaths) {58 // Add new project roots.59 for (const projectPath of projectPaths) {60 if (!this._subscriptionsByRoot.has(projectPath)) {61 const disposables = new _atom.CompositeDisposable(62 // Wait a bit before starting the initial search, since it's a heavy op.63 (0, (_scheduleIdleCallback || _load_scheduleIdleCallback()).default)(() => {64 this._initialSearch(projectPath).catch(err => {65 // RPC timeout errors can often happen here, but don't dispose the search.66 if (err instanceof (_nuclideRpc || _load_nuclideRpc()).RpcTimeoutError) {67 logger.warn(`Warmup fuzzy filename search for ${projectPath} hit the RPC timeout.`);68 } else {69 logger.error(`Error starting fuzzy filename search for ${projectPath}: ${err}`);70 this._disposeSearch(projectPath);71 }72 });73 }, { timeout: 5000 }));74 this._subscriptionsByRoot.set(projectPath, disposables);75 }76 }77 // Clean up removed project roots.78 for (const [projectPath] of this._subscriptionsByRoot) {79 if (!projectPaths.includes(projectPath)) {80 this._disposeSearch(projectPath);81 }82 }83 }84 _initialSearch(projectPath) {85 var _this = this;86 return (0, _asyncToGenerator.default)(function* () {87 const service = (0, (_nuclideRemoteConnection || _load_nuclideRemoteConnection()).getFuzzyFileSearchServiceByNuclideUri)(projectPath);88 const isAvailable = yield service.isFuzzySearchAvailableFor(projectPath);89 if (!isAvailable) {90 throw new Error('Nonexistent directory');91 }92 const disposables = _this._subscriptionsByRoot.get(projectPath);93 if (!(disposables != null)) {94 throw new Error('Invariant violation: "disposables != null"');95 }96 const busySignalDisposable = _this._busySignalProvider.displayMessage(`File search: indexing ${projectPath}`);97 disposables.add(busySignalDisposable);98 // It doesn't matter what the search term is. Empirically, doing an initial99 // search speeds up the next search much more than simply doing the setup100 // kicked off by 'fileSearchForDirectory'.101 try {102 yield service.queryFuzzyFile(projectPath, 'a', (0, (_utils || _load_utils()).getIgnoredNames)());103 } catch (err) {104 throw err;105 } finally {106 busySignalDisposable.dispose();107 disposables.remove(busySignalDisposable);108 }109 })();110 }111 _disposeSearch(projectPath) {112 try {113 const service = (0, (_nuclideRemoteConnection || _load_nuclideRemoteConnection()).getFuzzyFileSearchServiceByNuclideUri)(projectPath);114 service.disposeFuzzySearch(projectPath);115 } catch (err) {116 logger.error(`Error disposing fuzzy filename service for ${projectPath}`, err);117 } finally {118 const disposables = this._subscriptionsByRoot.get(projectPath);119 if (disposables != null) {120 disposables.dispose();121 this._subscriptionsByRoot.delete(projectPath);122 }123 }124 }125 registerProvider() {126 return (_FuzzyFileNameProvider || _load_FuzzyFileNameProvider()).default;127 }128 provideBusySignal() {129 return this._busySignalProvider;130 }131 dispose() {132 this._subscriptions.dispose();133 this._subscriptionsByRoot.forEach(disposables => disposables.dispose());134 this._subscriptionsByRoot.clear();135 }136}...
Project.js
Source:Project.js
1/* eslint-env node*/2'use strict';34const path = require('path');56const projectTypes = {7 module: 'module',8 theme: 'theme',9 containers: 'containers',10 '2sxc': '2sxc',11 other: 'other',12};1314const Project = class Project {15 constructor(name, projectPath, projectType) {16 this.name = name;17 this.path = projectPath;18 this.projectType = projectType;1920 const isModuleProject = this.projectType === projectTypes.module;2122 this.imageExtensions = ['jpg', 'gif', 'png', 'svg'];23 this.imageFileGlobs = this.imageExtensions.map(ext =>24 path.join(projectPath, `**/*.${ext}`)25 );2627 const defaultStylesDirPath = isModuleProject28 ? projectPath29 : path.join(projectPath, 'styles/');30 this.stylesDirPath = defaultStylesDirPath;31 this.stylesOutputDirPath = projectPath;32 this.lessFilesGlobs = [path.join(this.stylesDirPath, '**/*.less')];33 this.lessEntryFilesGlobs = isModuleProject34 ? [path.join(this.stylesDirPath, '**/module.less')]35 : [36 path.join(this.stylesDirPath, 'skin.less'),37 path.join(this.stylesDirPath, 'standalone/*.less'),38 ];3940 this.viewFilesGlobs = [41 path.join(projectPath, '**/*.ascx'),42 path.join(projectPath, '**/*.aspx'),43 path.join(projectPath, '**/*.cshtml'),44 path.join(projectPath, '**/*.vbhtml'),45 path.join(projectPath, '**/*.html'),46 path.join(projectPath, '**/*.htm'),47 ];48 this.solutionFilesGlobs = [path.join(projectPath, '**/*.sln')];49 this.nugetPackagesFilesGlobs = [50 path.join(projectPath, '**/packages.config'),51 ];52 this.nugetConfigFilesGlobs = [53 path.join(projectPath, '**/nuget.config'),54 ];55 this.nugetPackagesDirPath = path.join(projectPath, './packages');56 if (isModuleProject) {57 const testProjectsGlob = path.join(58 projectPath,59 '**/*.Tests.csproj'60 );61 this.primaryProjectGlobs = [62 path.join(projectPath, '**/*.csproj'),63 `!${testProjectsGlob}`,64 ];65 this.compilationOutputDirPath = 'Website/bin/';66 }6768 const minifiedScriptsGlob = path.join(projectPath, '**/*.min.js');69 this.javaScriptEntryFilesGlobs = [70 path.join(projectPath, '**/main.mjs'),71 ];72 this.javaScriptModuleFilesGlobs = [path.join(projectPath, '**/*.mjs')];73 this.javaScriptFilesGlobs = [74 path.join(projectPath, '**/*.js'),75 `!${minifiedScriptsGlob}`,76 ];77 if (isModuleProject) {78 const testScriptsGlob = path.join(79 projectPath,80 '*.Tests/Scripts/**/*.js'81 );82 this.javaScriptFilesGlobs.push(`!${testScriptsGlob}`);83 const nugetScriptsGlob = path.join(projectPath, 'packages/**/*.js');84 this.javaScriptFilesGlobs.push(`!${nugetScriptsGlob}`);85 }8687 this.elmEntryFilesGlobs = [path.join(projectPath, '**/Main.elm')];88 this.elmFilesGlobs = [path.join(projectPath, '**/*.elm')];89 this.elmTestFilesGlobs = [90 path.join(projectPath, '**/NodeTestRunner.elm'),91 ];9293 this.dependencyPackageOutputDirPath =94 'Website/Install/JavaScriptLibrary/';95 this.packageOutputDirPath =96 this.projectType === projectTypes.theme97 ? 'Website/Install/Skin/'98 : this.projectType === projectTypes.containers99 ? 'Website/Install/Container/'100 : 'Website/Install/Module/';101102 this.packageManifestGlobs = [path.join(projectPath, '**/*.dnn')];103 this.packageReleaseNotesGlobs = [104 path.join(projectPath, '**/ReleaseNotes*.htm'),105 ];106107 const fontGlobs = [108 path.join(projectPath, '**/*.woff'),109 path.join(projectPath, '**/*.woff2'),110 path.join(projectPath, '**/*.ttf'),111 path.join(projectPath, '**/*.eot'),112 path.join(projectPath, '**/*.otf'),113 ];114 const ignoreGlobs = [115 `!${path.join(projectPath, '**/bin/**')}`,116 `!${path.join(projectPath, '**/packages/**')}`,117 `!${path.join(projectPath, '**/Service References/**')}`,118 `!${path.join(projectPath, '**/_ReSharper.*/**')}`,119 `!${path.join(projectPath, '**/obj/**')}`,120 `!${path.join(projectPath, '**/.*')}`,121 `!${path.join(projectPath, '**/.*/**')}`,122 ];123124 if (this.projectType === projectTypes['2sxc']) {125 this.flattenPackageFiles = false;126 this.packageFilesGlobs = [127 minifiedScriptsGlob,128 path.join(projectPath, '**/*.resx'),129 path.join(projectPath, '**/*.xml'),130 path.join(projectPath, '**/*.css'),131 ].concat(132 this.imageFileGlobs,133 this.viewFilesGlobs,134 fontGlobs,135 ignoreGlobs136 );137138 this.packageResourcesGlobs = [];139 } else {140 this.flattenPackageFiles = true;141 this.packageFilesGlobs = [142 path.join(projectPath, '**/*.Cleanup.txt'),143 path.join(projectPath, '**/Readme.txt'),144 path.join(projectPath, '**/*.SqlDataProvider'),145 path.join(projectPath, '**/*.sql'),146 ].concat(ignoreGlobs);147148 this.packageResourcesGlobs = [149 minifiedScriptsGlob,150 path.join(projectPath, '**/*.asmx'),151 path.join(projectPath, '**/*.resx'),152 path.join(projectPath, '**/*.css'),153 path.join(projectPath, '**/*.pdf'),154 path.join(projectPath, '**/*.xml'),155 `!${path.join(projectPath, '**/CustomDictionary.xml')}`,156 `!${path.join(projectPath, '**/*.GhostDoc.xml')}`,157 path.join(projectPath, '**/*.xsd'),158 path.join(projectPath, '**/*.txt'),159 path.join(projectPath, '**/*.template'),160 path.join(projectPath, '**/*.json'),161 path.join(projectPath, '**/*.hbs'),162 ].concat(163 this.imageFileGlobs,164 this.viewFilesGlobs,165 fontGlobs,166 ignoreGlobs,167 this.packageFilesGlobs168 .filter(glob => glob[0] !== '!')169 .map(glob => `!${glob}`),170 this.packageReleaseNotesGlobs171 .filter(glob => glob[0] !== '!')172 .map(glob => `!${glob}`)173 );174 }175 }176};177178Project.projectTypes = projectTypes;179
...
project_new_spec.js
Source:project_new_spec.js
1import projectNew from '~/projects/project_new';2describe('New Project', () => {3 let $projectImportUrl;4 let $projectPath;5 beforeEach(() => {6 setFixtures(`7 <input id="project_import_url" />8 <input id="project_path" />9 `);10 $projectImportUrl = $('#project_import_url');11 $projectPath = $('#project_path');12 });13 describe('deriveProjectPathFromUrl', () => {14 const dummyImportUrl = `${gl.TEST_HOST}/dummy/import/url.git`;15 beforeEach(() => {16 projectNew.bindEvents();17 $projectPath.val('').keyup().val(dummyImportUrl);18 });19 it('does not change project path for disabled $projectImportUrl', () => {20 $projectImportUrl.attr('disabled', true);21 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);22 expect($projectPath.val()).toEqual(dummyImportUrl);23 });24 describe('for enabled $projectImportUrl', () => {25 beforeEach(() => {26 $projectImportUrl.attr('disabled', false);27 });28 it('does not change project path if it is set by user', () => {29 $projectPath.keyup();30 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);31 expect($projectPath.val()).toEqual(dummyImportUrl);32 });33 it('does not change project path for empty $projectImportUrl', () => {34 $projectImportUrl.val('');35 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);36 expect($projectPath.val()).toEqual(dummyImportUrl);37 });38 it('does not change project path for whitespace $projectImportUrl', () => {39 $projectImportUrl.val(' ');40 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);41 expect($projectPath.val()).toEqual(dummyImportUrl);42 });43 it('does not change project path for $projectImportUrl without slashes', () => {44 $projectImportUrl.val('has-no-slash');45 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);46 expect($projectPath.val()).toEqual(dummyImportUrl);47 });48 it('changes project path to last $projectImportUrl component', () => {49 $projectImportUrl.val('/this/is/last');50 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);51 expect($projectPath.val()).toEqual('last');52 });53 it('ignores trailing slashes in $projectImportUrl', () => {54 $projectImportUrl.val('/has/trailing/slash/');55 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);56 expect($projectPath.val()).toEqual('slash');57 });58 it('ignores fragment identifier in $projectImportUrl', () => {59 $projectImportUrl.val('/this/has/a#fragment-identifier/');60 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);61 expect($projectPath.val()).toEqual('a');62 });63 it('ignores query string in $projectImportUrl', () => {64 $projectImportUrl.val('/url/with?query=string');65 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);66 expect($projectPath.val()).toEqual('with');67 });68 it('ignores trailing .git in $projectImportUrl', () => {69 $projectImportUrl.val('/repository.git');70 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);71 expect($projectPath.val()).toEqual('repository');72 });73 it('changes project path for HTTPS URL in $projectImportUrl', () => {74 $projectImportUrl.val('https://username:password@gitlab.company.com/group/project.git');75 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);76 expect($projectPath.val()).toEqual('project');77 });78 it('changes project path for SSH URL in $projectImportUrl', () => {79 $projectImportUrl.val('git@gitlab.com:gitlab-org/gitlab-ce.git');80 projectNew.deriveProjectPathFromUrl($projectImportUrl, $projectPath);81 expect($projectPath.val()).toEqual('gitlab-ce');82 });83 });84 });...
getFilesToRemove.spec.js
Source:getFilesToRemove.spec.js
1const assert = require('assert');2const getFilesToRemove = require('../../src/getFilesToRemove');3const rootPath = `${process.cwd()}/test/fixtures`;4describe('Get files to remove', () => {5 it('should return only files which not contain the current build when no configuration is provided', async () => {6 const projectPath = `${rootPath}/packageV1`;7 const distPaths = [`${projectPath}/files`];8 const filesToExclude = [`${projectPath}/files/file1.txt`];9 const filesToRemove = await getFilesToRemove(projectPath, distPaths, filesToExclude);10 const expectedResult = [`${projectPath}/files/embed`];11 assert.deepEqual(filesToRemove, expectedResult);12 });13 it('should return only files which include in the configuration', async () => {14 const projectPath = `${rootPath}/packageV2`;15 const distPaths = [`${projectPath}/files`];16 const filesToRemove = await getFilesToRemove(projectPath, distPaths);17 const expectedResult = [`${projectPath}/files/file1.txt`];18 assert.deepEqual(filesToRemove, expectedResult);19 });20 it('should return only files that chosen in the configuration', async () => {21 const projectPath = `${rootPath}/packageV3`;22 const distPaths = [`${projectPath}/files`];23 const filesToExclude = [];24 const filesToRemove = await getFilesToRemove(projectPath, distPaths, filesToExclude);25 const expectedResult = [`${projectPath}/files/file1.txt`, `${projectPath}/files/embed/file2.txt`];26 assert.deepEqual(filesToRemove, expectedResult);27 });28 it('should return files which contains dist directories', async () => {29 const projectPath = `${rootPath}/packageV4`;30 const distPaths = [`${projectPath}/files`];31 const filesToRemove = await getFilesToRemove(projectPath, distPaths);32 const expectedResult = [`${projectPath}/files/embed/embed2/file3.txt`];33 assert.deepEqual(filesToRemove, expectedResult);34 });35 it('should return files inside of embeded directories', async () => {36 const projectPath = `${rootPath}/packageV1`;37 const distPaths = [`${projectPath}/files/embed`];38 const filesToExclude = [`${projectPath}/files/embed/embed2/file3.txt`];39 const filesToRemove = await getFilesToRemove(projectPath, distPaths, filesToExclude);40 const expectedResult = [`${projectPath}/files/embed/file2.txt`];41 assert.deepEqual(filesToRemove, expectedResult);42 });43 it("shouldn't return files outside of dist directories", async () => {44 const projectPath = `${rootPath}/packageV5`;45 const filesToRemove = await getFilesToRemove(projectPath, [`${__dirname}/files`]);46 const expectedResult = [];47 assert.deepEqual(filesToRemove, expectedResult);48 });49 it("shouldn't return files in block list", async () => {50 const projectPath = `${rootPath}/packageV5`;51 const distPaths = [`${projectPath}/files`];52 const filesToExclude = [`${projectPath}/files/embed/embed2/file3.txt`];53 const filesToRemove = await getFilesToRemove(projectPath, distPaths, filesToExclude);54 const expectedResult = [`${projectPath}/files/file1.txt`, `${projectPath}/files/embed/file2.txt`];55 assert.deepEqual(filesToRemove, expectedResult);56 });...
createProject.js
Source:createProject.js
1const util = require('util');2const exec = require('child_process').exec;3const spawn = require('child_process').spawn;4const logger = require('../logger');5const utils = require('../utils');6const projectTypes = require('../projectTypes');7const rimraf = require('rimraf');8const { projectNameSlug } = require('../utils/helpers');9module.exports = (10 projectName,11 templatePath,12 projectPath,13 command,14 callback,15 projectChoice,16 args = null17) => {18 let creator = null;19 if (command && args) {20 creator = spawn(command, args);21 creator.stdout.on('data', data => {22 logger('info', data);23 });24 creator.stderr.on('data', data => {25 logger('warning', data);26 });27 creator.on('disconnect', data => {28 logger('warning', 'Disconnect: ' + data);29 });30 creator.on('error', error => {31 logger('error', error);32 rimraf.sync(projectPath);33 });34 creator.on('exit', data => {35 logger('success', 'Exit: + ' + data.toString());36 proceedCreation(templatePath, projectPath, projectChoice, callback)37 });38 } else {39 proceedCreation(templatePath, projectPath, projectChoice, callback)40 }41};42function proceedCreation(templatePath, projectPath, projectChoice, callback) {43 callback();44 utils.createProjectContents(templatePath, projectPath);45 installDependencies(projectPath, projectChoice);46}47function installDependencies(projectPath, projectName) {48 logger('info', 'Installing dependencies. Please wait...');49 exec(50 `npm --prefix ${projectPath} install -s ${projectTypes[51 projectName52 ].dependencies.join(' ')} ${projectPath}`,53 (error, stdout, stderr) => {54 if (error) {55 logger('error', error);56 } else {57 logger('success', stdout);58 logger('warning', stderr);59 installDevDependencies(projectPath, projectName);60 }61 }62 );63}64function installDevDependencies(projectPath, projectName) {65 logger('info', 'Installing devDependencies. Please wait...');66 exec(67 `npm --prefix ${projectPath} install --save-dev ${projectTypes[68 projectName69 ].devDependencies.join(' ')} ${projectPath}`,70 (error, stdout, stderr) => {71 if (error) {72 logger('error', error);73 } else {74 logger('success', stdout);75 logger('warning', stderr);76 spawn(process.env.SHELL, { cwd: projectPath, stdio: 'inherit' });77 logger('success', 'Project setup finished! ENJOY!');78 }79 }80 );...
CreateTask.js
Source:CreateTask.js
1const global = require('../global')2const inquirer = require('inquirer')3const chalk = require('chalk')4const path = require('path')5const fs = require('fs-extra')6const { folder, ivry, shell } = require('../utils')7function start(projectName) {8 currentPath = path.resolve(process.cwd())9 let projectPath = currentPath10 if((typeof projectName == `boolean`) || !projectName || projectName == `.`) {11 console.log(chalk.green(`Creating project in current folder, ${projectPath}`))12 } else {13 projectName = projectName.toLowerCase().replace(/[^a-z0-9]/g, '')14 projectPath = folder.createProjectFolder(currentPath, projectName)15 console.log(chalk.green(`Creating folder name ${projectPath}`))16 }17 fs.copySync(`${__dirname}/../boilers/initial/`, projectPath)18 ivry.update(projectPath, 'projectName', path.basename(projectPath))19 ivry.update(projectPath, 'projectPath', projectPath)20 global.projectPath = projectPath21 shell.npmInitiate()22 .then(shell.npmInstall(`express`))23 .then(console.log)24}25module.exports = {26 start...
Using AI Code Generation
1module.exports = {2 {3 }4 {5 }6 "paths": {7 },8 "engineOptions": {9 },10};11module.exports = async (page, scenario, vp) => {12 console.log('onBefore.js');13 await require('puppeteer-backstop-utils')(page, scenario, vp);14 await page.evaluate(() => {15 window.projectPath = '/path/to/project/root';16 });17};18module.exports = async (page, scenario, vp) => {19 console.log('onReady.js');20 await page.evaluate(() => {21 console.log('projectPath', window.projectPath);22 console.log('location', window.location);23 });24};
Using AI Code Generation
1module.exports = {2 {3 },4 {5 },6 {7 },8 {9 }10 {11 }12 "paths": {13 },14 "engineOptions": {15 },16}
Using AI Code Generation
1var backstopjs = require('backstopjs');2var projectPath = backstopjs.projectPath;3console.log(projectPath);4{5 {6 },7 {8 },9 {10 },11 {12 },13 {14 }15 {16 }17 "paths": {18 },19}
Using AI Code Generation
1var projectPath = require('backstopjs/core/util/projectPath');2console.log(projectPath('backstop.json'));3var projectPath = require('backstopjs/core/util/projectPath');4console.log(projectPath('backstop.json'));5Your name to display (optional):6Your name to display (optional):7var projectPath = require('backstopjs/core/util/projectPath');8var backstopJsonPath = projectPath('backstop.json');
Using AI Code Generation
1var path = require('path');2var projectPath = path.resolve(__dirname, './');3var backstop = require('backstopjs');4backstop('reference', {5})6.then(function () {7 console.log('Reference complete!');8})9.catch(function (e) {10 console.log(e);11});12{13 {14 },15 {16 },17 {18 }19 {20 }21 "paths": {22 },23}
Using AI Code Generation
1const backstop = require('backstopjs');2const fs = require('fs');3const path = require('path');4const backstopConfig = require('./backstop.json');5const projectPath = backstop.projectPath(backstopConfig);6const test = async () => {7 const files = await fs.promises.readdir(projectPath);8 console.log(files);9 const fullPaths = files.map((file) => path.join(projectPath, file));10 console.log(fullPaths);11};12test();
Using AI Code Generation
1var projectPath = require('backstopjs/core/util/projectPath');2console.log(projectPath('test.js'));3var projectPath = require('backstopjs/core/util/projectPath');4console.log(projectPath('test.js'));5var projectPath = require('backstopjs/core/util/projectPath');6console.log(projectPath('test.js'));7var projectPath = require('backstopjs/core/util/projectPath');8console.log(projectPath('test.js'));9var projectPath = require('backstopjs/core/util/projectPath');10console.log(projectPath('test.js'));11var projectPath = require('backstopjs/core/util/projectPath');12console.log(projectPath('test.js'));13var projectPath = require('backstopjs/core/util/projectPath');14console.log(projectPath('test.js'));15var projectPath = require('backstopjs/core/util/projectPath');16console.log(projectPath('test.js'));17var projectPath = require('backstopjs/core/util/project
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!!