Best JavaScript code snippet using best
Gruntfile_.js
Source: Gruntfile_.js
1module.exports = function(grunt) {2 // load all grunt tasks3 require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);4 // configurable paths5 var configPath = {6 public_temp_web: 'public',7 public_web: './server',8 public_temp_mobile: 'www',9 public_mobile: './mobile',10 dev: 'frontend_dev'11 };12 // Project configuration.13 grunt.initConfig({14 configPath: configPath,15 concat: {16 options: {},17 dist: {18 src: [19 '<%= configPath.dev %>' + '/vendor/libs/bootstrap/css/bootstrap.min.css',20 '<%= configPath.dev %>' + '/vendor/libs/bootstrap/css/superhero.css',21 '<%= configPath.dev %>' + '/import/animate.css',22 '<%= configPath.dev %>' + '/css/style.css'23 ],24 dest: '<%= configPath.dev %>' + '/css/style.css'25 }26 },27 clean: {28 public_temp_web: '<%= configPath.public_temp_web %>',29 public_temp_mobile: '<%= configPath.public_temp_mobile %>'30 },31 copy: {32 web: {33 files: [34 {expand: true, src: ['<%= configPath.dev %>' + '/img'], dest: '<%= configPath.public_temp_web %>', flatten: true},35 {expand: true, src: ['<%= configPath.dev %>' + '/img/*'], dest: '<%= configPath.public_temp_web %>/img', flatten: true},36 {expand: true, src: ['<%= configPath.dev %>' + '/css'], dest: '<%= configPath.public_temp_web %>', flatten: true},37 {expand: true, src: ['<%= configPath.dev %>' + '/css/style.css'], dest: '<%= configPath.public_temp_web %>/css', flatten: true},38 {expand: true, src: ['<%= configPath.dev %>' + '/vendor/libs/require/require.js'], dest: '<%= configPath.public_temp_web %>', flatten: true},39 {expand: true, src: ['<%= configPath.dev %>' + '/index.html'], dest: '<%= configPath.public_temp_web %>', flatten: true},40 {expand: true, src: ['<%= configPath.dev %>' + '/landing.html'], dest: '<%= configPath.public_temp_web %>', flatten: true},41 {expand: true, src: ['<%= configPath.dev %>' + '/fonts'], dest: '<%= configPath.public_temp_web %>', flatten: true},42 {expand: true, src: ['<%= configPath.dev %>' + '/fonts/*'], dest: '<%= configPath.public_temp_web %>/fonts', flatten: true}43 ]44 },45 web_finish: {46 files: [47 {expand: true, src: ['<%= configPath.public_temp_web %>' + '/**'], dest: '<%= configPath.public_web %>'}48 ]49 },50 mobile: {51 files: [52 {expand: true, src: ['<%= configPath.dev %>' + '/img'], dest: '<%= configPath.public_temp_mobile %>', flatten: true},53 {expand: true, src: ['<%= configPath.dev %>' + '/img/*'], dest: '<%= configPath.public_temp_mobile %>/img', flatten: true},54 {expand: true, src: ['<%= configPath.dev %>' + '/css'], dest: '<%= configPath.public_temp_mobile %>', flatten: true},55 {expand: true, src: ['<%= configPath.dev %>' + '/css/style.css'], dest: '<%= configPath.public_temp_mobile %>/css', flatten: true},56 {expand: true, src: ['<%= configPath.dev %>' + '/vendor/libs/require/require.js'], dest: '<%= configPath.public_temp_mobile %>', flatten: true},57 {expand: true, src: ['<%= configPath.dev %>' + '/index.html'], dest: '<%= configPath.public_temp_mobile %>', flatten: true},58 {expand: true, src: ['<%= configPath.dev %>' + '/landing.html'], dest: '<%= configPath.public_temp_mobile %>', flatten: true},59 {expand: true, src: ['<%= configPath.dev %>' + '/fonts'], dest: '<%= configPath.public_temp_mobile %>', flatten: true},60 {expand: true, src: ['<%= configPath.dev %>' + '/fonts/*'], dest: '<%= configPath.public_temp_mobile %>/fonts', flatten: true}61 ]62 },63 mobile_finish: {64 files: [65 {expand: true, src: ['<%= configPath.public_temp_mobile %>' + '/**'], dest: '<%= configPath.public_mobile %>'}66 ]67 }68 },69 // Configuration to be run (and then tested).70 stylus: {71 compile: {72 options: {73 compress: false74 },75 files: {76 '<%= configPath.dev %>/css/style.css': '<%= configPath.dev %>/css/stylus/style.styl'77 }78 }79 },80 watch: {81 all: {82 tasks: ['build_all'],83 files: [84 '<%= configPath.dev %>'+'/css/stylus/*.styl',85 '<%= configPath.dev %>/js/**/*.js',86 '<%= configPath.dev %>/js/**/*.html',87 '<%= configPath.dev %>/index.html'88 ]89 },90 web: {91 tasks: ['build_web'],92 files: [93 '<%= configPath.dev %>'+'/css/stylus/*.styl',94 '<%= configPath.dev %>/js/**/*.js',95 '<%= configPath.dev %>/js/**/*.html',96 '<%= configPath.dev %>/index.html'97 ]98 },99 mobile: {100 tasks: ['build_mobile'],101 files: [102 '<%= configPath.dev %>'+'/css/stylus/*.styl',103 '<%= configPath.dev %>/js/**/*.js',104 '<%= configPath.dev %>/js/**/*.html',105 '<%= configPath.dev %>/index.html'106 ]107 }108 },109 requirejs: {110 web: {111 options: {112 baseUrl: ".",113 mainConfigFile: "config.js",114 name: "./frontend_dev/js/apps/web.js",115 out: '<%= configPath.public_temp_web %>' + "/script.js",116 optimize: "none"117 }118 },119 mobile: {120 options: {121 baseUrl: ".",122 mainConfigFile: "config.js",123 name: "./frontend_dev/js/apps/mobile.js",124 out: '<%= configPath.public_temp_mobile %>' + "/script.js",125 optimize: "none"126 }127 }128 }129 });130 // By default, lint and run all tests.131 grunt.registerTask('default', ['watch']);132 grunt.registerTask('build_web', [133 'stylus',134 'concat',135 'clean:public_temp_web',136 'requirejs:web',137 'copy:web',138 'copy:web_finish',139 'clean:public_temp_web'140 ]);141 grunt.registerTask('build_mobile', [142 'stylus',143 'concat',144 'clean:public_temp_mobile',145 'requirejs:mobile',146 'copy:mobile',147 'copy:mobile_finish',148 'clean:public_temp_mobile'149 ]);150 grunt.registerTask('build_all', [151 'build_web',152 'build_mobile'153 ]);...
find-config.ts
Source: find-config.ts
1import type { CompilerSystem, Diagnostic } from '../declarations';2import { isString, normalizePath, buildError } from '@utils';3export const findConfig = async (opts: { sys: CompilerSystem; configPath: string }) => {4 const sys = opts.sys;5 const cwd = sys.getCurrentDirectory();6 const results = {7 configPath: null as string,8 rootDir: normalizePath(cwd),9 diagnostics: [] as Diagnostic[],10 };11 let configPath = opts.configPath;12 if (isString(configPath)) {13 if (!sys.platformPath.isAbsolute(configPath)) {14 // passed in a custom rindo config location15 // but it's relative, so prefix the cwd16 configPath = normalizePath(sys.platformPath.join(cwd, configPath));17 } else {18 // config path already an absolute path, we're good here19 configPath = normalizePath(opts.configPath);20 }21 } else {22 // nothing was passed in, use the current working directory23 configPath = results.rootDir;24 }25 const stat = await sys.stat(configPath);26 if (stat.error) {27 const diagnostic = buildError(results.diagnostics);28 diagnostic.absFilePath = configPath;29 diagnostic.header = `Invalid config path`;30 diagnostic.messageText = `Config path "${configPath}" not found`;31 return results;32 }33 if (stat.isFile) {34 results.configPath = configPath;35 results.rootDir = sys.platformPath.dirname(configPath);36 } else if (stat.isDirectory) {37 // this is only a directory, so let's make some assumptions38 for (const configName of ['rindo.config.ts', 'rindo.config.js']) {39 const testConfigFilePath = sys.platformPath.join(configPath, configName);40 const stat = await sys.stat(testConfigFilePath);41 if (stat.isFile) {42 results.configPath = testConfigFilePath;43 results.rootDir = sys.platformPath.dirname(testConfigFilePath);44 break;45 }46 }47 }48 return results;...
configLoader.js
Source: configLoader.js
1import fs from 'fs';2import path from 'path';3import yaml from 'js-yaml';4const log = {5 info: message => console.log(message.green),6 error: message => console.error(message.red)7}8export default (configPath) => {9 if (!fs.existsSync(configPath)) {10 log.error(`Supplied --path '${configPath}' doesn't exist`.red);11 return process.exit(1);12 }13 if(/(\.yml)|(\.yaml)/.test(configPath)) {14 return yaml.safeLoad(fs.readFileSync(configPath));15 }16 if (/(\.json)/.test(configPath)) {17 return JSON.parse(fs.readFileSync(configPath));18 }19 if (/(\.js)/.test(configPath)) {20 try {21 let config = require(resolvePath(configPath));22 if (config === null || typeof config !== 'object' || Object.keys(config).length == 0) {23 log.error('Config file must export an object!\n' + CONFIG_SYNTAX_HELP);24 return process.exit(1);25 }26 return config;27 } catch (e) {28 if (e.code === 'MODULE_NOT_FOUND' && e.message.indexOf(configPath) !== -1) {29 log.error('File %s does not exist!', configPath);30 } else {31 log.error('Invalid config file!\n ' + e.stack);32 }33 return process.exit(1);34 }35 }36}37function resolvePath(configPath) {38 if (path.isAbsolute(configPath)) {39 return configPath;40 }41 return path.resolve(process.cwd(), configPath);42}43const CONFIG_SYNTAX_HELP =44 ' module.exports = {\n' +45 ' // your config\n' +...
clean.js
Source: clean.js
1const gulp = require('gulp'),2 del = require('del');3/**4 *5 * @type {{src, dest, errorHandler}}6 */7const configPath = require('../config/configPath');8/**9 * @description Gulp clean - clean dest folder before build project.10 */11gulp.task('clean', function() {12 return del.sync([13 configPath.dest.root + '/**/*',14 configPath.src.root + '/img/**',15 configPath.src.root + '/media/**',16 configPath.src.root + '/icon/**',17 '!' + configPath.dest.root + '/img',18 '!' + configPath.dest.root + '/img/**/*',19 '!' + configPath.dest.root + '/media',20 '!' + configPath.dest.root + '/media/**/*',21 '!' + configPath.dest.root + '/icon',22 '!' + configPath.dest.root + '/icon/**/*',23 '!' + configPath.src.root + '/img',24 '!' + configPath.src.root + '/icon',25 '!' + configPath.src.root + '/icon/**'26 ]);...
Using AI Code Generation
1var bestPractice = require('best-practice');2var path = require('path');3var configPath = path.resolve(__dirname, 'config.json');4bestPractice.configPath(configPath);5bestPractice.check('test4.js', function(err, result) {6 if (err) {7 console.log(err);8 } else {9 console.log(result);10 }11});12{ test4.js: { 'no-console': 1 } }
Using AI Code Generation
1var bestPractices = require('best-practices');2var path = require('path');3var configPath = bestPractices.configPath();4console.log('configPath: ' + configPath);5var bestPractices = require('best-practices');6var path = require('path');7var config = bestPractices.config();8console.log('config: ' + JSON.stringify(config));9var bestPractices = require('best-practices');10var path = require('path');11var config = bestPractices.config();12console.log('config: ' + JSON.stringify(config));13config = {14 {
Using AI Code Generation
1var BestPractice = require('best-practice');2var bp = new BestPractice();3bp.configPath('./test2.js');4var BestPractice = require('best-practice');5var bp = new BestPractice();6bp.configPath('./test2.js');7bp.set('age', 23);8var BestPractice = require('best-practice');9var bp = new BestPractice();10bp.configPath('./test2.js');11bp.set('age', 23);12bp.save();13var BestPractice = require('best-practice');14var bp = new BestPractice();15bp.configPath('./test2.js');16bp.set('age', 23);17bp.save();18bp.set('age', 24);19bp.save();20var BestPractice = require('best-practice');21var bp = new BestPractice();22bp.configPath('./test2.js');23bp.set('age', 23);24bp.save();25bp.set('age', 24);26bp.save();27bp.configPath('./test3.js');28var BestPractice = require('best-practice');29var bp = new BestPractice();30bp.configPath('./test2.js');31bp.set('age', 23);32bp.save();33bp.set('age', 24);
Using AI Code Generation
1var BestPractice = require('./bestPractice').BestPractice;2var bestPractice = new BestPractice();3bestPractice.configPath('/home/username/Downloads');4bestPractice.run();5var configPath = '/var/www';6var fs = require('fs');7var BestPractice = function() {8 this.configPath = function(path) {9 configPath = path;10 };11 this.run = function() {12 console.log('configPath: ' + configPath);13 };14};15exports.BestPractice = BestPractice;
Using AI Code Generation
1var BestPractice = require('./BestPractice');2var bestPractice = new BestPractice();3bestPractice.configPath('C:\\Users\\Sridhar\\Documents\\GitHub\\nodejs\\node_modules\\bestpractice\\config');4var result = bestPractice.analyze('C:\\Users\\Sridhar\\Documents\\GitHub\\nodejs\\node_modules\\bestpractice\\test\\test.js');5console.log(result);6var config = require('./config');7var fs = require('fs');8var path = require('path');9var esprima = require('esprima');10var escodegen = require('escodegen');11var escope = require('escope');12var estraverse = require('estraverse');13var esmangle = require('esmangle');14var escomplex = require('escomplex');15var escomplexReport = require('escomplex-report');16var escomplexJs = require('escomplex-js');17var escomplexJsx = require('escomplex-jsx');18var escomplexFlow = require('escomplex-flow');19var escomplexTypescript = require('escomplex-typescript');20var escomplexLodash = require('escomplex-lodash');21var escomplexAngular = require('escomplex-angular');22var escomplexJquery = require('escomplex-jquery');23var escomplexMocha = require('escomplex-mocha');24var escomplexPhp = require('escomplex-php');25var escomplexPython = require('escomplex-python');26var escomplexRuby = require('escomplex-ruby');27var escomplexSwift = require('escomplex-swift');28var escomplexGo = require('escomplex-go');29var escomplexRust = require('escomplex-rust');30var escomplexHaskell = require('escomplex-haskell');31var escomplexDart = require('escomplex-dart');32var escomplexCoffeescript = require('escomplex-coffeescript');33var escomplexLua = require('escomplex-lua');34var escomplexClojure = require('escomplex-clojure');35var escomplexPerl = require('escomplex-perl');36var escomplexSass = require('escomplex-sass');37var escomplexLess = require('escomplex-less');38var escomplexStylus = require('escomplex-stylus');39var escomplexC = require('escomplex-c');40var escomplexCsharp = require('escomplex
Using AI Code Generation
1var config = require('best-practice');2var configPath = config.configPath();3console.log("configPath: " + configPath);4var fs = require('fs');5var configFileContents = fs.readFileSync(configPath, 'utf8');6console.log("configFileContents: " + configFileContents);7var config = require('best-practice');8var configPath = config.configPath();9console.log("configPath: " + configPath);10var fs = require('fs');11var configFileContents = fs.readFileSync(configPath, 'utf8');12console.log("configFileContents: " + configFileContents);13var config = require('best-practice');14var configPath = config.configPath();15console.log("configPath: " + configPath);16var fs = require('fs');17var configFileContents = fs.readFileSync(configPath, 'utf8');18console.log("configFileContents: " + configFileContents);19var config = require('best-practice');20var configPath = config.configPath();21console.log("configPath: " + configPath);22var fs = require('fs');23var configFileContents = fs.readFileSync(configPath, 'utf8');24console.log("configFileContents: " + configFileContents);25var config = require('best-practice');26var configPath = config.configPath();27console.log("configPath: " + configPath);28var fs = require('fs');29var configFileContents = fs.readFileSync(configPath, 'utf8');30console.log("configFileContents: " + configFileContents);
Check out the latest blogs from LambdaTest on this topic:
LambdaTest has recently received two notable awards from the leading business software directory FinancesOnline after their experts were impressed with our test platform’s capabilities in accelerating one’s development process.
The layout of a web page is one of the most important features of a web page. It can affect the traffic inflow by a significant margin. At times, a designer may come up with numerous layout ideas and sometimes he/she may struggle the entire day to come up with one. Moreover, design becomes even more important when it comes to ensuring cross browser compatibility.
Chrome is hands down the most used browsers by developers and users alike. It is the primary reason why there is such a solid chrome community and why there is a huge list of Chrome Extensions targeted at developers.
In a startup, the major strength of the people is that they are multitaskers. Be it anything, the founders and the core team wears multiple hats and takes complete responsibilities to get the ball rolling. From designing to deploying, from development to testing, everything takes place under the hawk eyes of founders and the core members.
We are in the era of the ‘Heads down’ generation. Ever wondered how much time you spend on your smartphone? Well, let us give you an estimate. With over 2.5 billion smartphone users, an average human spends approximately 2 Hours 51 minutes on their phone every day as per ComScore’s 2017 report. The number increases by an hour if we include the tab users as well!
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!!