How to use continueProcessing method in Cypress

Best JavaScript code snippet using cypress

lessc-rhino-1.7.3.js

Source:lessc-rhino-1.7.3.js Github

copy

Full Screen

1/* Less.js v1.7.3 RHINO | Copyright (c) 2009-2014, Alexis Sellier <self@cloudhead.net> */2/*global name:true, less, loadStyleSheet, os */3function formatError(ctx, options) {4 options = options || {};5 var message = "";6 var extract = ctx.extract;7 var error = [];8// var stylize = options.color ? require('./lessc_helper').stylize : function (str) { return str; };9 var stylize = function (str) { return str; };10 // only output a stack if it isn't a less error11 if (ctx.stack && !ctx.type) { return stylize(ctx.stack, 'red'); }12 if (!ctx.hasOwnProperty('index') || !extract) {13 return ctx.stack || ctx.message;14 }15 if (typeof(extract[0]) === 'string') {16 error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey'));17 }18 if (typeof(extract[1]) === 'string') {19 var errorTxt = ctx.line + ' ';20 if (extract[1]) {21 errorTxt += extract[1].slice(0, ctx.column) +22 stylize(stylize(stylize(extract[1][ctx.column], 'bold') +23 extract[1].slice(ctx.column + 1), 'red'), 'inverse');24 }25 error.push(errorTxt);26 }27 if (typeof(extract[2]) === 'string') {28 error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey'));29 }30 error = error.join('\n') + stylize('', 'reset') + '\n';31 message += stylize(ctx.type + 'Error: ' + ctx.message, 'red');32 if (ctx.filename) {33 message += stylize(' in ', 'red') + ctx.filename +34 stylize(' on line ' + ctx.line + ', column ' + (ctx.column + 1) + ':', 'grey');35 }36 message += '\n' + error;37 if (ctx.callLine) {38 message += stylize('from ', 'red') + (ctx.filename || '') + '/n';39 message += stylize(ctx.callLine, 'grey') + ' ' + ctx.callExtract + '/n';40 }41 return message;42}43function writeError(ctx, options) {44 options = options || {};45 if (options.silent) { return; }46 var message = formatError(ctx, options);47 throw new Error(message);48}49function loadStyleSheet(sheet, callback, reload, remaining) {50 var endOfPath = Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')),51 sheetName = name.slice(0, endOfPath + 1) + sheet.href,52 contents = sheet.contents || {},53 input = readFile(sheetName);54 input = input.replace(/^\xEF\xBB\xBF/, '');55 56 contents[sheetName] = input;57 58 var parser = new less.Parser({59 paths: [sheet.href.replace(/[\w\.-]+$/, '')],60 contents: contents61 });62 parser.parse(input, function (e, root) {63 if (e) {64 return writeError(e);65 }66 try {67 callback(e, root, input, sheet, { local: false, lastModified: 0, remaining: remaining }, sheetName);68 } catch(e) {69 writeError(e);70 }71 });72}73less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {74 var href = file;75 if (currentFileInfo && currentFileInfo.currentDirectory && !/^\//.test(file)) {76 href = less.modules.path.join(currentFileInfo.currentDirectory, file);77 }78 var path = less.modules.path.dirname(href);79 var newFileInfo = {80 currentDirectory: path + '/',81 filename: href82 };83 if (currentFileInfo) {84 newFileInfo.entryPath = currentFileInfo.entryPath;85 newFileInfo.rootpath = currentFileInfo.rootpath;86 newFileInfo.rootFilename = currentFileInfo.rootFilename;87 newFileInfo.relativeUrls = currentFileInfo.relativeUrls;88 } else {89 newFileInfo.entryPath = path;90 newFileInfo.rootpath = less.rootpath || path;91 newFileInfo.rootFilename = href;92 newFileInfo.relativeUrls = env.relativeUrls;93 }94 var j = file.lastIndexOf('/');95 if(newFileInfo.relativeUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) {96 var relativeSubDirectory = file.slice(0, j+1);97 newFileInfo.rootpath = newFileInfo.rootpath + relativeSubDirectory; // append (sub|sup) directory path of imported file98 }99 newFileInfo.currentDirectory = path;100 newFileInfo.filename = href;101 var data = null;102 try {103 data = readFile(href);104 } catch (e) {105 callback({ type: 'File', message: "'" + less.modules.path.basename(href) + "' wasn't found" });106 return;107 }108 try {109 callback(null, data, href, newFileInfo, { lastModified: 0 });110 } catch (e) {111 callback(e, null, href);112 }113};114function writeFile(filename, content) {115 var fstream = new java.io.FileWriter(filename);116 var out = new java.io.BufferedWriter(fstream);117 out.write(content);118 out.close();119}120// Command line integration via Rhino121(function (args) {122 var options = {123 depends: false,124 compress: false,125 cleancss: false,126 max_line_len: -1,127 optimization: 1,128 silent: false,129 verbose: false,130 lint: false,131 paths: [],132 color: true,133 strictImports: false,134 rootpath: '',135 relativeUrls: false,136 ieCompat: true,137 strictMath: false,138 strictUnits: false139 };140 var continueProcessing = true,141 currentErrorcode;142 var checkArgFunc = function(arg, option) {143 if (!option) {144 print(arg + " option requires a parameter");145 continueProcessing = false;146 return false;147 }148 return true;149 };150 var checkBooleanArg = function(arg) {151 var onOff = /^((on|t|true|y|yes)|(off|f|false|n|no))$/i.exec(arg);152 if (!onOff) {153 print(" unable to parse "+arg+" as a boolean. use one of on/t/true/y/yes/off/f/false/n/no");154 continueProcessing = false;155 return false;156 }157 return Boolean(onOff[2]);158 };159 var warningMessages = "";160 var sourceMapFileInline = false;161 args = args.filter(function (arg) {162 var match = arg.match(/^-I(.+)$/);163 164 if (match) {165 options.paths.push(match[1]);166 return false;167 }168 169 match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i);170 if (match) { arg = match[1]; } // was (?:=([^\s]*)), check!171 else { return arg; }172 switch (arg) {173 case 'v':174 case 'version':175 console.log("lessc " + less.version.join('.') + " (Less Compiler) [JavaScript]");176 continueProcessing = false;177 break;178 case 'verbose':179 options.verbose = true;180 break;181 case 's':182 case 'silent':183 options.silent = true;184 break;185 case 'l':186 case 'lint':187 options.lint = true;188 break;189 case 'strict-imports':190 options.strictImports = true;191 break;192 case 'h':193 case 'help':194 //TODO195// require('../lib/less/lessc_helper').printUsage();196 continueProcessing = false;197 break;198 case 'x':199 case 'compress':200 options.compress = true;201 break;202 case 'M':203 case 'depends':204 options.depends = true;205 break;206 case 'yui-compress':207 warningMessages += "yui-compress option has been removed. assuming clean-css.";208 options.cleancss = true;209 break;210 case 'clean-css':211 options.cleancss = true;212 break;213 case 'max-line-len':214 if (checkArgFunc(arg, match[2])) {215 options.maxLineLen = parseInt(match[2], 10);216 if (options.maxLineLen <= 0) {217 options.maxLineLen = -1;218 }219 }220 break;221 case 'no-color':222 options.color = false;223 break;224 case 'no-ie-compat':225 options.ieCompat = false;226 break;227 case 'no-js':228 options.javascriptEnabled = false;229 break;230 case 'include-path':231 if (checkArgFunc(arg, match[2])) {232 options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')233 .map(function(p) {234 if (p) {235// return path.resolve(process.cwd(), p);236 return p;237 }238 });239 }240 break;241 case 'O0': options.optimization = 0; break;242 case 'O1': options.optimization = 1; break;243 case 'O2': options.optimization = 2; break;244 case 'line-numbers':245 if (checkArgFunc(arg, match[2])) {246 options.dumpLineNumbers = match[2];247 }248 break;249 case 'source-map':250 if (!match[2]) {251 options.sourceMap = true;252 } else {253 options.sourceMap = match[2];254 }255 break;256 case 'source-map-rootpath':257 if (checkArgFunc(arg, match[2])) {258 options.sourceMapRootpath = match[2];259 }260 break;261 case 'source-map-basepath':262 if (checkArgFunc(arg, match[2])) {263 options.sourceMapBasepath = match[2];264 }265 break;266 case 'source-map-map-inline':267 sourceMapFileInline = true;268 options.sourceMap = true;269 break;270 case 'source-map-less-inline':271 options.outputSourceFiles = true;272 break;273 case 'source-map-url':274 if (checkArgFunc(arg, match[2])) {275 options.sourceMapURL = match[2];276 }277 break;278 case 'source-map-output-map-file':279 if (checkArgFunc(arg, match[2])) {280 options.writeSourceMap = function(sourceMapContent) {281 writeFile(match[2], sourceMapContent);282 };283 }284 break;285 case 'rp':286 case 'rootpath':287 if (checkArgFunc(arg, match[2])) {288 options.rootpath = match[2].replace(/\\/g, '/');289 }290 break;291 case "ru":292 case "relative-urls":293 options.relativeUrls = true;294 break;295 case "sm":296 case "strict-math":297 if (checkArgFunc(arg, match[2])) {298 options.strictMath = checkBooleanArg(match[2]);299 }300 break;301 case "su":302 case "strict-units":303 if (checkArgFunc(arg, match[2])) {304 options.strictUnits = checkBooleanArg(match[2]);305 }306 break;307 default:308 console.log('invalid option ' + arg);309 continueProcessing = false;310 }311 });312 if (!continueProcessing) {313 return;314 }315 var name = args[0];316 if (name && name != '-') {317// name = path.resolve(process.cwd(), name);318 }319 var output = args[1];320 var outputbase = args[1];321 if (output) {322 options.sourceMapOutputFilename = output;323// output = path.resolve(process.cwd(), output);324 if (warningMessages) {325 console.log(warningMessages);326 }327 }328// options.sourceMapBasepath = process.cwd();329// options.sourceMapBasepath = '';330 if (options.sourceMap === true) {331 console.log("output: " + output);332 if (!output && !sourceMapFileInline) {333 console.log("the sourcemap option only has an optional filename if the css filename is given");334 return;335 }336 options.sourceMapFullFilename = options.sourceMapOutputFilename + ".map";337 options.sourceMap = less.modules.path.basename(options.sourceMapFullFilename);338 } else if (options.sourceMap) {339 options.sourceMapOutputFilename = options.sourceMap;340 }341 342 if (!name) {343 console.log("lessc: no inout files");344 console.log("");345 // TODO346// require('../lib/less/lessc_helper').printUsage();347 currentErrorcode = 1;348 return;349 }350// var ensureDirectory = function (filepath) {351// var dir = path.dirname(filepath),352// cmd,353// existsSync = fs.existsSync || path.existsSync;354// if (!existsSync(dir)) {355// if (mkdirp === undefined) {356// try {mkdirp = require('mkdirp');}357// catch(e) { mkdirp = null; }358// }359// cmd = mkdirp && mkdirp.sync || fs.mkdirSync;360// cmd(dir);361// }362// };363 if (options.depends) {364 if (!outputbase) {365 console.log("option --depends requires an output path to be specified");366 return;367 }368 console.log(outputbase + ": ");369 }370 if (!name) {371 console.log('No files present in the fileset');372 quit(1);373 }374 var input = null;375 try {376 input = readFile(name, 'utf-8');377 } catch (e) {378 console.log('lesscss: couldn\'t open file ' + name);379 quit(1);380 }381 options.filename = name;382 var result;383 try {384 var parser = new less.Parser(options);385 parser.parse(input, function (e, root) {386 if (e) {387 writeError(e, options);388 quit(1);389 } else {390 result = root.toCSS(options);391 if (output) {392 writeFile(output, result);393 console.log("Written to " + output);394 } else {395 print(result);396 }397 quit(0);398 }399 });400 }401 catch(e) {402 writeError(e, options);403 quit(1);404 }...

Full Screen

Full Screen

lessc-rhino-1.6.2.js

Source:lessc-rhino-1.6.2.js Github

copy

Full Screen

1/* LESS.js v1.6.2 RHINO | Copyright (c) 2009-2014, Alexis Sellier <self@cloudhead.net> */2/*global name:true, less, loadStyleSheet, os */3function formatError(ctx, options) {4 options = options || {};5 var message = "";6 var extract = ctx.extract;7 var error = [];8// var stylize = options.color ? require('./lessc_helper').stylize : function (str) { return str; };9 var stylize = function (str) { return str; };10 // only output a stack if it isn't a less error11 if (ctx.stack && !ctx.type) { return stylize(ctx.stack, 'red'); }12 if (!ctx.hasOwnProperty('index') || !extract) {13 return ctx.stack || ctx.message;14 }15 if (typeof(extract[0]) === 'string') {16 error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey'));17 }18 if (typeof(extract[1]) === 'string') {19 var errorTxt = ctx.line + ' ';20 if (extract[1]) {21 errorTxt += extract[1].slice(0, ctx.column) +22 stylize(stylize(stylize(extract[1][ctx.column], 'bold') +23 extract[1].slice(ctx.column + 1), 'red'), 'inverse');24 }25 error.push(errorTxt);26 }27 if (typeof(extract[2]) === 'string') {28 error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey'));29 }30 error = error.join('\n') + stylize('', 'reset') + '\n';31 message += stylize(ctx.type + 'Error: ' + ctx.message, 'red');32 if (ctx.filename) {33 message += stylize(' in ', 'red') + ctx.filename +34 stylize(' on line ' + ctx.line + ', column ' + (ctx.column + 1) + ':', 'grey');35 }36 message += '\n' + error;37 if (ctx.callLine) {38 message += stylize('from ', 'red') + (ctx.filename || '') + '/n';39 message += stylize(ctx.callLine, 'grey') + ' ' + ctx.callExtract + '/n';40 }41 return message;42}43function writeError(ctx, options) {44 options = options || {};45 if (options.silent) { return; }46 print(formatError(ctx, options));47}48function loadStyleSheet(sheet, callback, reload, remaining) {49 var endOfPath = Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')),50 sheetName = name.slice(0, endOfPath + 1) + sheet.href,51 contents = sheet.contents || {},52 input = readFile(sheetName);53 input = input.replace(/^\xEF\xBB\xBF/, '');54 55 contents[sheetName] = input;56 57 var parser = new less.Parser({58 paths: [sheet.href.replace(/[\w\.-]+$/, '')],59 contents: contents60 });61 parser.parse(input, function (e, root) {62 if (e) {63 return writeError(e);64 }65 try {66 callback(e, root, input, sheet, { local: false, lastModified: 0, remaining: remaining }, sheetName);67 } catch(e) {68 writeError(e);69 }70 });71}72less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {73 var href = file;74 if (currentFileInfo && currentFileInfo.currentDirectory && !/^\//.test(file)) {75 href = less.modules.path.join(currentFileInfo.currentDirectory, file);76 }77 var path = less.modules.path.dirname(href);78 var newFileInfo = {79 currentDirectory: path + '/',80 filename: href81 };82 if (currentFileInfo) {83 newFileInfo.entryPath = currentFileInfo.entryPath;84 newFileInfo.rootpath = currentFileInfo.rootpath;85 newFileInfo.rootFilename = currentFileInfo.rootFilename;86 newFileInfo.relativeUrls = currentFileInfo.relativeUrls;87 } else {88 newFileInfo.entryPath = path;89 newFileInfo.rootpath = less.rootpath || path;90 newFileInfo.rootFilename = href;91 newFileInfo.relativeUrls = env.relativeUrls;92 }93 var j = file.lastIndexOf('/');94 if(newFileInfo.relativeUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) {95 var relativeSubDirectory = file.slice(0, j+1);96 newFileInfo.rootpath = newFileInfo.rootpath + relativeSubDirectory; // append (sub|sup) directory path of imported file97 }98 newFileInfo.currentDirectory = path;99 newFileInfo.filename = href;100 var data = null;101 try {102 data = readFile(href);103 } catch (e) {104 callback({ type: 'File', message: "'" + less.modules.path.basename(href) + "' wasn't found" });105 return;106 }107 try {108 callback(null, data, href, newFileInfo, { lastModified: 0 });109 } catch (e) {110 callback(e, null, href);111 }112};113function writeFile(filename, content) {114 var fstream = new java.io.FileWriter(filename);115 var out = new java.io.BufferedWriter(fstream);116 out.write(content);117 out.close();118}119// Command line integration via Rhino120(function (args) {121 var options = {122 depends: false,123 compress: false,124 cleancss: false,125 max_line_len: -1,126 optimization: 1,127 silent: false,128 verbose: false,129 lint: false,130 paths: [],131 color: true,132 strictImports: false,133 rootpath: '',134 relativeUrls: false,135 ieCompat: true,136 strictMath: false,137 strictUnits: false138 };139 var continueProcessing = true,140 currentErrorcode;141 var checkArgFunc = function(arg, option) {142 if (!option) {143 print(arg + " option requires a parameter");144 continueProcessing = false;145 return false;146 }147 return true;148 };149 var checkBooleanArg = function(arg) {150 var onOff = /^((on|t|true|y|yes)|(off|f|false|n|no))$/i.exec(arg);151 if (!onOff) {152 print(" unable to parse "+arg+" as a boolean. use one of on/t/true/y/yes/off/f/false/n/no");153 continueProcessing = false;154 return false;155 }156 return Boolean(onOff[2]);157 };158 var warningMessages = "";159 var sourceMapFileInline = false;160 args = args.filter(function (arg) {161 var match = arg.match(/^-I(.+)$/);162 163 if (match) {164 options.paths.push(match[1]);165 return false;166 }167 168 match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i);169 if (match) { arg = match[1]; } // was (?:=([^\s]*)), check!170 else { return arg; }171 switch (arg) {172 case 'v':173 case 'version':174 console.log("lessc " + less.version.join('.') + " (LESS Compiler) [JavaScript]");175 continueProcessing = false;176 break;177 case 'verbose':178 options.verbose = true;179 break;180 case 's':181 case 'silent':182 options.silent = true;183 break;184 case 'l':185 case 'lint':186 options.lint = true;187 break;188 case 'strict-imports':189 options.strictImports = true;190 break;191 case 'h':192 case 'help':193 //TODO194// require('../lib/less/lessc_helper').printUsage();195 continueProcessing = false;196 break;197 case 'x':198 case 'compress':199 options.compress = true;200 break;201 case 'M':202 case 'depends':203 options.depends = true;204 break;205 case 'yui-compress':206 warningMessages += "yui-compress option has been removed. assuming clean-css.";207 options.cleancss = true;208 break;209 case 'clean-css':210 options.cleancss = true;211 break;212 case 'max-line-len':213 if (checkArgFunc(arg, match[2])) {214 options.maxLineLen = parseInt(match[2], 10);215 if (options.maxLineLen <= 0) {216 options.maxLineLen = -1;217 }218 }219 break;220 case 'no-color':221 options.color = false;222 break;223 case 'no-ie-compat':224 options.ieCompat = false;225 break;226 case 'no-js':227 options.javascriptEnabled = false;228 break;229 case 'include-path':230 if (checkArgFunc(arg, match[2])) {231 options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')232 .map(function(p) {233 if (p) {234// return path.resolve(process.cwd(), p);235 return p;236 }237 });238 }239 break;240 case 'O0': options.optimization = 0; break;241 case 'O1': options.optimization = 1; break;242 case 'O2': options.optimization = 2; break;243 case 'line-numbers':244 if (checkArgFunc(arg, match[2])) {245 options.dumpLineNumbers = match[2];246 }247 break;248 case 'source-map':249 if (!match[2]) {250 options.sourceMap = true;251 } else {252 options.sourceMap = match[2];253 }254 break;255 case 'source-map-rootpath':256 if (checkArgFunc(arg, match[2])) {257 options.sourceMapRootpath = match[2];258 }259 break;260 case 'source-map-basepath':261 if (checkArgFunc(arg, match[2])) {262 options.sourceMapBasepath = match[2];263 }264 break;265 case 'source-map-map-inline':266 sourceMapFileInline = true;267 options.sourceMap = true;268 break;269 case 'source-map-less-inline':270 options.outputSourceFiles = true;271 break;272 case 'source-map-url':273 if (checkArgFunc(arg, match[2])) {274 options.sourceMapURL = match[2];275 }276 break;277 case 'source-map-output-map-file':278 if (checkArgFunc(arg, match[2])) {279 options.writeSourceMap = function(sourceMapContent) {280 writeFile(match[2], sourceMapContent);281 };282 }283 break;284 case 'rp':285 case 'rootpath':286 if (checkArgFunc(arg, match[2])) {287 options.rootpath = match[2].replace(/\\/g, '/');288 }289 break;290 case "ru":291 case "relative-urls":292 options.relativeUrls = true;293 break;294 case "sm":295 case "strict-math":296 if (checkArgFunc(arg, match[2])) {297 options.strictMath = checkBooleanArg(match[2]);298 }299 break;300 case "su":301 case "strict-units":302 if (checkArgFunc(arg, match[2])) {303 options.strictUnits = checkBooleanArg(match[2]);304 }305 break;306 default:307 console.log('invalid option ' + arg);308 continueProcessing = false;309 }310 });311 if (!continueProcessing) {312 return;313 }314 var name = args[0];315 if (name && name != '-') {316// name = path.resolve(process.cwd(), name);317 }318 var output = args[1];319 var outputbase = args[1];320 if (output) {321 options.sourceMapOutputFilename = output;322// output = path.resolve(process.cwd(), output);323 if (warningMessages) {324 console.log(warningMessages);325 }326 }327// options.sourceMapBasepath = process.cwd();328// options.sourceMapBasepath = '';329 if (options.sourceMap === true) {330 console.log("output: " + output);331 if (!output && !sourceMapFileInline) {332 console.log("the sourcemap option only has an optional filename if the css filename is given");333 return;334 }335 options.sourceMapFullFilename = options.sourceMapOutputFilename + ".map";336 options.sourceMap = less.modules.path.basename(options.sourceMapFullFilename);337 } else if (options.sourceMap) {338 options.sourceMapOutputFilename = options.sourceMap;339 }340 341 if (!name) {342 console.log("lessc: no inout files");343 console.log("");344 // TODO345// require('../lib/less/lessc_helper').printUsage();346 currentErrorcode = 1;347 return;348 }349// var ensureDirectory = function (filepath) {350// var dir = path.dirname(filepath),351// cmd,352// existsSync = fs.existsSync || path.existsSync;353// if (!existsSync(dir)) {354// if (mkdirp === undefined) {355// try {mkdirp = require('mkdirp');}356// catch(e) { mkdirp = null; }357// }358// cmd = mkdirp && mkdirp.sync || fs.mkdirSync;359// cmd(dir);360// }361// };362 if (options.depends) {363 if (!outputbase) {364 console.log("option --depends requires an output path to be specified");365 return;366 }367 console.log(outputbase + ": ");368 }369 if (!name) {370 console.log('No files present in the fileset');371 quit(1);372 }373 var input = null;374 try {375 input = readFile(name, 'utf-8');376 } catch (e) {377 console.log('lesscss: couldn\'t open file ' + name);378 quit(1);379 }380 options.filename = name;381 var result;382 try {383 var parser = new less.Parser(options);384 parser.parse(input, function (e, root) {385 if (e) {386 writeError(e, options);387 quit(1);388 } else {389 result = root.toCSS(options);390 if (output) {391 writeFile(output, result);392 console.log("Written to " + output);393 } else {394 print(result);395 }396 quit(0);397 }398 });399 }400 catch(e) {401 writeError(e, options);402 quit(1);403 }404 console.log("done");...

Full Screen

Full Screen

lessc.js

Source:lessc.js Github

copy

Full Screen

1#!/usr/bin/env node2var path = require('path'),3 fs = require('../lib/less/fs'),4 os = require('os'),5 mkdirp;6var less = require('../lib/less');7var args = process.argv.slice(1);8var options = {9 depends: false,10 compress: false,11 cleancss: false,12 max_line_len: -1,13 optimization: 1,14 silent: false,15 verbose: false,16 lint: false,17 paths: [],18 color: true,19 strictImports: false,20 insecure: false,21 rootpath: '',22 relativeUrls: false,23 ieCompat: true,24 strictMath: false,25 strictUnits: false,26 globalVariables: '',27 modifyVariables: '',28 urlArgs: ''29};30var cleancssOptions = {};31var continueProcessing = true,32 currentErrorcode;33// calling process.exit does not flush stdout always34// so use this to set the exit code35process.on('exit', function() { process.reallyExit(currentErrorcode) });36var checkArgFunc = function(arg, option) {37 if (!option) {38 console.log(arg + " option requires a parameter");39 continueProcessing = false;40 return false;41 }42 return true;43};44var checkBooleanArg = function(arg) {45 var onOff = /^((on|t|true|y|yes)|(off|f|false|n|no))$/i.exec(arg);46 if (!onOff) {47 console.log(" unable to parse "+arg+" as a boolean. use one of on/t/true/y/yes/off/f/false/n/no");48 continueProcessing = false;49 return false;50 }51 return Boolean(onOff[2]);52};53var parseVariableOption = function(option) {54 var parts = option.split('=', 2);55 return '@' + parts[0] + ': ' + parts[1] + ';\n';56};57var warningMessages = "";58var sourceMapFileInline = false;59args = args.filter(function (arg) {60 var match;61 if (match = arg.match(/^-I(.+)$/)) {62 options.paths.push(match[1]);63 return false;64 }65 if (match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i)) { arg = match[1] }66 else { return arg }67 switch (arg) {68 case 'v':69 case 'version':70 console.log("lessc " + less.version.join('.') + " (Less Compiler) [JavaScript]");71 continueProcessing = false;72 case 'verbose':73 options.verbose = true;74 break;75 case 's':76 case 'silent':77 options.silent = true;78 break;79 case 'l':80 case 'lint':81 options.lint = true;82 break;83 case 'strict-imports':84 options.strictImports = true;85 break;86 case 'h':87 case 'help':88 require('../lib/less/lessc_helper').printUsage();89 continueProcessing = false;90 case 'x':91 case 'compress':92 options.compress = true;93 break;94 case 'insecure':95 options.insecure = true;96 break;97 case 'M':98 case 'depends':99 options.depends = true;100 break;101 case 'yui-compress':102 warningMessages += "yui-compress option has been removed. ignoring.";103 break;104 case 'clean-css':105 options.cleancss = true;106 break;107 case 'max-line-len':108 if (checkArgFunc(arg, match[2])) {109 options.maxLineLen = parseInt(match[2], 10);110 if (options.maxLineLen <= 0) {111 options.maxLineLen = -1;112 }113 }114 break;115 case 'no-color':116 options.color = false;117 break;118 case 'no-ie-compat':119 options.ieCompat = false;120 break;121 case 'no-js':122 options.javascriptEnabled = false;123 break;124 case 'include-path':125 if (checkArgFunc(arg, match[2])) {126 options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')127 .map(function(p) {128 if (p) {129 return path.resolve(process.cwd(), p);130 }131 });132 }133 break;134 case 'O0': options.optimization = 0; break;135 case 'O1': options.optimization = 1; break;136 case 'O2': options.optimization = 2; break;137 case 'line-numbers':138 if (checkArgFunc(arg, match[2])) {139 options.dumpLineNumbers = match[2];140 }141 break;142 case 'source-map':143 if (!match[2]) {144 options.sourceMap = true;145 } else {146 options.sourceMap = match[2];147 }148 break;149 case 'source-map-rootpath':150 if (checkArgFunc(arg, match[2])) {151 options.sourceMapRootpath = match[2];152 }153 break;154 case 'source-map-basepath':155 if (checkArgFunc(arg, match[2])) {156 options.sourceMapBasepath = match[2];157 }158 break;159 case 'source-map-map-inline':160 sourceMapFileInline = true;161 options.sourceMap = true;162 break;163 case 'source-map-less-inline':164 options.outputSourceFiles = true;165 break;166 case 'source-map-url':167 if (checkArgFunc(arg, match[2])) {168 options.sourceMapURL = match[2];169 }170 break;171 case 'rp':172 case 'rootpath':173 if (checkArgFunc(arg, match[2])) {174 options.rootpath = match[2].replace(/\\/g, '/');175 }176 break;177 case "ru":178 case "relative-urls":179 options.relativeUrls = true;180 break;181 case "sm":182 case "strict-math":183 if (checkArgFunc(arg, match[2])) {184 options.strictMath = checkBooleanArg(match[2]);185 }186 break;187 case "su":188 case "strict-units":189 if (checkArgFunc(arg, match[2])) {190 options.strictUnits = checkBooleanArg(match[2]);191 }192 break;193 case "global-var":194 if (checkArgFunc(arg, match[2])) {195 options.globalVariables += parseVariableOption(match[2]);196 }197 break;198 case "modify-var":199 if (checkArgFunc(arg, match[2])) {200 options.modifyVariables += parseVariableOption(match[2]);201 }202 break;203 case "clean-option":204 var cleanOptionArgs = match[2].split(":");205 switch(cleanOptionArgs[0]) {206 case "--keep-line-breaks":207 case "-b":208 cleancssOptions.keepBreaks = true;209 break;210 case "--s0":211 cleancssOptions.keepSpecialComments = 0;212 break;213 case "--s1":214 cleancssOptions.keepSpecialComments = 1;215 break;216 case "--skip-advanced":217 cleancssOptions.noAdvanced = true;218 break;219 case "--advanced":220 cleancssOptions.noAdvanced = false;221 break;222 case "--compatibility":223 cleancssOptions.compatibility = cleanOptionArgs[1];224 break;225 case "--rounding-precision":226 cleancssOptions.roundingPrecision = Number(cleanOptionArgs[1]);227 break;228 default:229 console.log("unrecognised clean-css option '" + cleanOptionArgs[0] + "'");230 console.log("we support only arguments that make sense for less, '--keep-line-breaks', '-b'");231 console.log("'--s0', '--s1', '--advanced', '--skip-advanced', '--compatibility', '--rounding-precision'");232 continueProcessing = false;233 currentErrorcode = 1;234 break;235 }236 break;237 case 'url-args':238 if (checkArgFunc(arg, match[2])) {239 options.urlArgs = match[2];240 }241 break;242 default:243 require('../lib/less/lessc_helper').printUsage();244 continueProcessing = false;245 currentErrorcode = 1;246 break;247 }248});249if (!continueProcessing) {250 return;251}252var input = args[1];253var inputbase = args[1];254if (input && input != '-') {255 input = path.resolve(process.cwd(), input);256}257var output = args[2];258var outputbase = args[2];259if (output) {260 options.sourceMapOutputFilename = output;261 output = path.resolve(process.cwd(), output);262 if (warningMessages) {263 console.log(warningMessages);264 }265}266options.sourceMapBasepath = options.sourceMapBasepath || (input ? path.dirname(input) : process.cwd());267if (options.sourceMap === true) {268 if (!output && !sourceMapFileInline) {269 console.log("the sourcemap option only has an optional filename if the css filename is given");270 return;271 }272 options.sourceMapFullFilename = options.sourceMapOutputFilename + ".map";273 options.sourceMap = path.basename(options.sourceMapFullFilename);274}275if (options.cleancss && options.sourceMap) {276 console.log("the cleancss option is not compatible with sourcemap support at the moment. See Issue #1656");277 return;278}279if (! input) {280 console.log("lessc: no input files");281 console.log("");282 require('../lib/less/lessc_helper').printUsage();283 currentErrorcode = 1;284 return;285}286var ensureDirectory = function (filepath) {287 var dir = path.dirname(filepath),288 cmd,289 existsSync = fs.existsSync || path.existsSync;290 if (!existsSync(dir)) {291 if (mkdirp === undefined) {292 try {mkdirp = require('mkdirp');}293 catch(e) { mkdirp = null; }294 }295 cmd = mkdirp && mkdirp.sync || fs.mkdirSync;296 cmd(dir);297 }298};299if (options.depends) {300 if (!outputbase) {301 console.log("option --depends requires an output path to be specified");302 return;303 }304 process.stdout.write(outputbase + ": ");305}306if (!sourceMapFileInline) {307 var writeSourceMap = function(output) {308 var filename = options.sourceMapFullFilename || options.sourceMap;309 ensureDirectory(filename);310 fs.writeFileSync(filename, output, 'utf8');311 };312}313var parseLessFile = function (e, data) {314 if (e) {315 console.log("lessc: " + e.message);316 currentErrorcode = 1;317 return;318 }319 data = options.globalVariables + data + '\n' + options.modifyVariables;320 options.paths = [path.dirname(input)].concat(options.paths);321 options.filename = input;322 var parser = new(less.Parser)(options);323 parser.parse(data, function (err, tree) {324 if (err) {325 less.writeError(err, options);326 currentErrorcode = 1;327 return;328 } else if (options.depends) {329 for(var file in parser.imports.files) {330 process.stdout.write(file + " ")331 }332 console.log("");333 } else {334 try {335 if (options.lint) { writeSourceMap = function() {} }336 var css = tree.toCSS({337 silent: options.silent,338 verbose: options.verbose,339 ieCompat: options.ieCompat,340 compress: options.compress,341 cleancss: options.cleancss,342 cleancssOptions: cleancssOptions,343 sourceMap: Boolean(options.sourceMap),344 sourceMapFilename: options.sourceMap,345 sourceMapURL: options.sourceMapURL,346 sourceMapOutputFilename: options.sourceMapOutputFilename,347 sourceMapBasepath: options.sourceMapBasepath,348 sourceMapRootpath: options.sourceMapRootpath || "",349 outputSourceFiles: options.outputSourceFiles,350 writeSourceMap: writeSourceMap,351 maxLineLen: options.maxLineLen,352 strictMath: options.strictMath,353 strictUnits: options.strictUnits,354 urlArgs: options.urlArgs355 });356 if(!options.lint) {357 if (output) {358 ensureDirectory(output);359 fs.writeFileSync(output, css, 'utf8');360 if (options.verbose) {361 console.log('lessc: wrote ' + output);362 }363 } else {364 process.stdout.write(css);365 }366 }367 } catch (e) {368 less.writeError(e, options);369 currentErrorcode = 2;370 return;371 }372 }373 });374};375if (input != '-') {376 fs.readFile(input, 'utf8', parseLessFile);377} else {378 process.stdin.resume();379 process.stdin.setEncoding('utf8');380 var buffer = '';381 process.stdin.on('data', function(data) {382 buffer += data;383 });384 process.stdin.on('end', function() {385 parseLessFile(false, buffer);386 });...

Full Screen

Full Screen

lessc

Source:lessc Github

copy

Full Screen

1#!/usr/bin/env node2var path = require('path'),3 fs = require('fs'),4 sys = require('util'),5 os = require('os');6var less = require('../lib/less');7var args = process.argv.slice(1);8var options = {9 compress: false,10 yuicompress: false,11 optimization: 1,12 silent: false,13 paths: [],14 color: true,15 strictImports: false,16 rootpath: '',17 relativeUrls: false18};19var continueProcessing = true,20 currentErrorcode;21// calling process.exit does not flush stdout always22// so use this to set the exit code23process.on('exit', function() { process.reallyExit(currentErrorcode) });24args = args.filter(function (arg) {25 var match;26 if (match = arg.match(/^-I(.+)$/)) {27 options.paths.push(match[1]);28 return false;29 }30 if (match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=([^\s]+))?$/i)) { arg = match[1] }31 else { return arg }32 switch (arg) {33 case 'v':34 case 'version':35 sys.puts("lessc " + less.version.join('.') + " (LESS Compiler) [JavaScript]");36 continueProcessing = false;37 case 'verbose':38 options.verbose = true;39 break;40 case 's':41 case 'silent':42 options.silent = true;43 break;44 case 'strict-imports':45 options.strictImports = true;46 break;47 case 'h':48 case 'help':49 require('../lib/less/lessc_helper').printUsage();50 continueProcessing = false;51 case 'x':52 case 'compress':53 options.compress = true;54 break;55 case 'yui-compress':56 options.yuicompress = true;57 break;58 case 'no-color':59 options.color = false;60 break;61 case 'include-path':62 if (!match[2]) {63 sys.puts("include-path option requires a parameter");64 continueProcessing = false;65 } else {66 options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')67 .map(function(p) {68 if (p) {69 return path.resolve(process.cwd(), p);70 }71 });72 }73 break;74 case 'O0': options.optimization = 0; break;75 case 'O1': options.optimization = 1; break;76 case 'O2': options.optimization = 2; break;77 case 'line-numbers':78 options.dumpLineNumbers = match[2];79 break;80 case 'rp':81 case 'rootpath':82 if (!match[2]) {83 sys.puts("rootpath option requires a parameter");84 continueProcessing = false;85 } else {86 options.rootpath = path.normalize(match[2] + '/').replace('\\', '/');87 }88 break;89 case "ru":90 case "relative-urls":91 options.relativeUrls = true;92 break;93 }94});95if (!continueProcessing) {96 return;97}98var input = args[1];99if (input && input != '-') {100 input = path.resolve(process.cwd(), input);101}102var output = args[2];103if (output) {104 output = path.resolve(process.cwd(), output);105}106if (! input) {107 sys.puts("lessc: no input files");108 sys.puts("");109 require('../lib/less/lessc_helper').printUsage();110 currentErrorcode = 1;111 return;112}113var ensureDirectory = function (filepath) {114 var dir = path.dirname(filepath),115 existsSync = fs.existsSync || path.existsSync;116 if (!existsSync(dir)) {117 fs.mkdirSync(dir);118 }119};120var parseLessFile = function (e, data) {121 if (e) {122 sys.puts("lessc: " + e.message);123 currentErrorcode = 1;124 return;125 }126 new(less.Parser)({127 paths: [path.dirname(input)].concat(options.paths),128 optimization: options.optimization,129 filename: input,130 rootpath: options.rootpath,131 relativeUrls: options.relativeUrls,132 strictImports: options.strictImports,133 dumpLineNumbers: options.dumpLineNumbers134 }).parse(data, function (err, tree) {135 if (err) {136 less.writeError(err, options);137 currentErrorcode = 1;138 return;139 } else {140 try {141 var css = tree.toCSS({142 compress: options.compress,143 yuicompress: options.yuicompress144 });145 if (output) {146 ensureDirectory(output);147 fs.writeFileSync(output, css, 'utf8');148 if (options.verbose) {149 console.log('lessc: wrote ' + output);150 }151 } else {152 sys.print(css);153 }154 } catch (e) {155 less.writeError(e, options);156 currentErrorcode = 2;157 return;158 }159 }160 });161};162if (input != '-') {163 fs.readFile(input, 'utf8', parseLessFile);164} else {165 process.stdin.resume();166 process.stdin.setEncoding('utf8');167 var buffer = '';168 process.stdin.on('data', function(data) {169 buffer += data;170 });171 process.stdin.on('end', function() {172 parseLessFile(false, buffer);173 });...

Full Screen

Full Screen

DiffUpdateProcessors.js

Source:DiffUpdateProcessors.js Github

copy

Full Screen

1/* license-start2 * 3 * Copyright (C) 2008 - 2014 Crispico Software, <http://www.crispico.com/>.4 * 5 * This program is free software: you can redistribute it and/or modify6 * it under the terms of the GNU General Public License as published by7 * the Free Software Foundation version 3.8 * 9 * This program is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU General Public License for more details, at <http://www.gnu.org/licenses/>.13 * 14 * license-end15 */16 17var AddEntityDiffUpdateProcessor = function() { };18AddEntityDiffUpdateProcessor.prototype.applyDiffUpdate = function(entityRegistry, diffUpdate) {19 var continueProcessing = entityRegistry.entityOperationsAdapter.preProcessUpdate(entityRegistry, diffUpdate);20 if (!continueProcessing) {21 return;22 }23 var entity = diffUpdate.entity;24 entityRegistry.mergeEntity(entity);25 entityRegistry.entityOperationsAdapter.postProcessUpdate(entityRegistry, diffUpdate);26};2728var RemoveEntityDiffUpdateProcessor = function() { };29RemoveEntityDiffUpdateProcessor.prototype.applyDiffUpdate = function(entityRegistry, diffUpdate) {30 var continueProcessing = entityRegistry.entityOperationsAdapter.preProcessUpdate(entityRegistry, diffUpdate);31 if (!continueProcessing) {32 return;33 }34 entityRegistry.remove(diffUpdate.entityUid);35 entityRegistry.entityOperationsAdapter.postProcessUpdate(entityRegistry, diffUpdate);36};3738var PropertiesDiffUpdateProcessor = function() { };39PropertiesDiffUpdateProcessor.prototype.applyDiffUpdate = function(entityRegistry, diffUpdate) {40 var continueProcessing = entityRegistry.entityOperationsAdapter.preProcessUpdate(entityRegistry, diffUpdate);41 if (!continueProcessing) {42 return;43 }44 entityRegistry.setProperties(diffUpdate.entityUid, diffUpdate.properties);45 entityRegistry.entityOperationsAdapter.postProcessUpdate(entityRegistry, diffUpdate);46};4748var InitialInfoDiffUpdateProcessor = function() { };49InitialInfoDiffUpdateProcessor.prototype.applyDiffUpdate = function(entityRegistry, diffUpdate) {50 51}; ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.pause()4 cy.continueProcessing()5 })6})

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('continueProcessing', () => {2 cy.get('button').contains('Continue').click();3});4describe('test', () => {5 it('test', () => {6 cy.get('input').type('test');7 cy.continueProcessing();8 });9});10cy.get('div').contains('test').should('exist');11cy.get('div').contains('test').then((element) => {12 expect(element).exist;13});14cy.get('div').contains('test').should('have.length', 1);

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Continue processing', () => {2 it('should continue processing', () => {3 cy.continueProcessing();4 });5});6Cypress.Commands.add('continueProcessing', () => {7 cy.window().then(win => {8 win.onbeforeunload = null;9 });10});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { continueProcessing } = require('cypress-continue-processing');2const { expect } = require('chai');3const { Given, When, Then } = require('cypress-cucumber-preprocessor/steps');4Given('I am on the homepage', function () {5});6When('I search for {string}', function (searchTerm) {7 cy.get('input[name="q"]').type(searchTerm);8 cy.get('input[type="submit"]').click();9});10Then('I should see the {string} in the results', function (searchTerm) {11 cy.get('h3').contains(searchTerm).should('be.visible');12 continueProcessing();13});14import { addContinueProcessingToCypress } from 'cypress-continue-processing';15addContinueProcessingToCypress();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', function() {2 it('test', function() {3 cy.get('h1').should('contain', 'Kitchen Sink')4 cy.wait(5000)5 cy.continueProcessing()6 })7})8I have tried to use the cy.wait() to wait for the response, but I

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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