How to use fs.chmod method in Cypress

Best JavaScript code snippet using cypress

Gruntfile.js

Source:Gruntfile.js Github

copy

Full Screen

1/*jshint camelcase: false*/2module.exports = function (grunt) {3 'use strict';4 // load all grunt tasks5 require('time-grunt')(grunt);6 require('load-grunt-tasks')(grunt);7 // configurable paths8 var config = {9 app: 'app',10 dist: 'dist',11 distMac32: 'dist/macOS',12 distMac64: 'dist/macOS',13 distLinux32: 'dist/Linux32',14 distLinux64: 'dist/Linux64',15 distWin: 'dist/Win',16 tmp: 'buildTmp',17 resources: 'resources'18 };19 grunt.initConfig({20 config: config,21 clean: {22 dist: {23 files: [{24 dot: true,25 src: [26 '<%= config.dist %>/*',27 '<%= config.tmp %>/*'28 ]29 }]30 },31 distMac32: {32 files: [{33 dot: true,34 src: [35 '<%= config.distMac32 %>/*',36 '<%= config.tmp %>/*'37 ]38 }]39 },40 distMac64: {41 files: [{42 dot: true,43 src: [44 '<%= config.distMac64 %>/*',45 '<%= config.tmp %>/*'46 ]47 }]48 },49 distLinux64: {50 files: [{51 dot: true,52 src: [53 '<%= config.distLinux64 %>/*',54 '<%= config.tmp %>/*'55 ]56 }]57 },58 distLinux32: {59 files: [{60 dot: true,61 src: [62 '<%= config.distLinux32 %>/*',63 '<%= config.tmp %>/*'64 ]65 }]66 },67 distWin: {68 files: [{69 dot: true,70 src: [71 '<%= config.distWin %>/*',72 '<%= config.tmp %>/*'73 ]74 }]75 }76 },77 jshint: {78 options: {79 jshintrc: '.jshintrc'80 },81 files: '<%= config.app %>/js/*.js'82 },83 copy: {84 appLinux: {85 files: [{86 expand: true,87 cwd: '<%= config.app %>',88 dest: '<%= config.distLinux64 %>/app.nw',89 src: '**'90 }]91 },92 appLinux32: {93 files: [{94 expand: true,95 cwd: '<%= config.app %>',96 dest: '<%= config.distLinux32 %>/app.nw',97 src: '**'98 }]99 },100 appMacos32: {101 files: [{102 expand: true,103 cwd: '<%= config.app %>',104 dest: '<%= config.distMac32 %>/node-webkit.app/Contents/Resources/app.nw',105 src: '**'106 }, {107 expand: true,108 cwd: '<%= config.resources %>/mac/',109 dest: '<%= config.distMac32 %>/node-webkit.app/Contents/',110 filter: 'isFile',111 src: '*.plist'112 }, {113 expand: true,114 cwd: '<%= config.resources %>/mac/',115 dest: '<%= config.distMac32 %>/node-webkit.app/Contents/Resources/',116 filter: 'isFile',117 src: '*.icns'118 }, {119 expand: true,120 cwd: '<%= config.app %>/../node_modules/',121 dest: '<%= config.distMac32 %>/node-webkit.app/Contents/Resources/app.nw/node_modules/',122 src: '**'123 }]124 },125 appMacos64: {126 files: [{127 expand: true,128 cwd: '<%= config.app %>',129 dest: '<%= config.distMac64 %>/node-webkit.app/Contents/Resources/app.nw',130 src: '**'131 }, {132 expand: true,133 cwd: '<%= config.resources %>/mac/',134 dest: '<%= config.distMac64 %>/node-webkit.app/Contents/',135 filter: 'isFile',136 src: '*.plist'137 }, {138 expand: true,139 cwd: '<%= config.resources %>/mac/',140 dest: '<%= config.distMac64 %>/node-webkit.app/Contents/Resources/',141 filter: 'isFile',142 src: '*.icns'143 }, {144 expand: true,145 cwd: '<%= config.app %>/../node_modules/',146 dest: '<%= config.distMac64 %>/node-webkit.app/Contents/Resources/app.nw/node_modules/',147 src: '**'148 }]149 },150 webkit32: {151 files: [{152 expand: true,153 cwd: '<%=config.resources %>/node-webkit/MacOS32',154 dest: '<%= config.distMac32 %>/',155 src: '**'156 }]157 },158 webkit64: {159 files: [{160 expand: true,161 cwd: '<%=config.resources %>/node-webkit/MacOS64',162 dest: '<%= config.distMac64 %>/',163 src: '**'164 }]165 },166 copyWinToTmp: {167 files: [{168 expand: true,169 cwd: '<%= config.resources %>/node-webkit/Windows/',170 dest: '<%= config.tmp %>/',171 src: '**'172 }]173 }174 },175 compress: {176 appToTmp: {177 options: {178 archive: '<%= config.tmp %>/app.zip'179 },180 files: [{181 expand: true,182 cwd: '<%= config.app %>',183 src: ['**']184 }]185 },186 finalWindowsApp: {187 options: {188 archive: '<%= config.distWin %>/MyMD.zip'189 },190 files: [{191 expand: true,192 cwd: '<%= config.tmp %>',193 src: ['**']194 }]195 }196 },197 rename: {198 macApp32: {199 files: [{200 src: '<%= config.distMac32 %>/node-webkit.app',201 dest: '<%= config.distMac32 %>/MyMD.app'202 }]203 },204 macApp64: {205 files: [{206 src: '<%= config.distMac64 %>/node-webkit.app',207 dest: '<%= config.distMac64 %>/MyMD.app'208 }]209 },210 zipToApp: {211 files: [{212 src: '<%= config.tmp %>/app.zip',213 dest: '<%= config.tmp %>/app.nw'214 }]215 }216 }217 });218 grunt.registerTask('chmod32', 'Add lost Permissions.', function () {219 var fs = require('fs'),220 path = config.distMac32 + '/MyMD.app/Contents/';221 if (fs.existsSync(path + 'Frameworks/node-webkit Helper EH.app/Contents/MacOS/node-webkit Helper EH')) {222 fs.chmodSync(path + 'Frameworks/node-webkit Helper EH.app/Contents/MacOS/node-webkit Helper EH', '555');223 } else {224 fs.chmodSync(path + 'Frameworks/nwjs Helper EH.app/Contents/MacOS/nwjs Helper EH', '555');225 }226 if (fs.existsSync(path + 'Frameworks/node-webkit Helper NP.app/Contents/MacOS/node-webkit Helper NP')) {227 fs.chmodSync(path + 'Frameworks/node-webkit Helper NP.app/Contents/MacOS/node-webkit Helper NP', '555');228 } else {229 fs.chmodSync(path + 'Frameworks/nwjs Helper NP.app/Contents/MacOS/nwjs Helper NP', '555');230 }231 if (fs.existsSync(path + 'Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper')) {232 fs.chmodSync(path + 'Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper', '555');233 } else {234 fs.chmodSync(path + 'Frameworks/nwjs Helper.app/Contents/MacOS/nwjs Helper', '555');235 }236 if (fs.existsSync(path + 'MacOS/node-webkit')) {237 fs.chmodSync(path + 'MacOS/node-webkit', '555');238 } else {239 fs.chmodSync(path + 'MacOS/nwjs', '555');240 }241 });242 grunt.registerTask('chmod64', 'Add lost Permissions.', function () {243 var fs = require('fs'),244 path = config.distMac64 + '/MyMD.app/Contents/';245 if (fs.existsSync(path + 'Frameworks/node-webkit Helper EH.app/Contents/MacOS/node-webkit Helper EH')) {246 fs.chmodSync(path + 'Frameworks/node-webkit Helper EH.app/Contents/MacOS/node-webkit Helper EH', '555');247 } else {248 fs.chmodSync(path + 'Frameworks/nwjs Helper EH.app/Contents/MacOS/nwjs Helper EH', '555');249 }250 if (fs.existsSync(path + 'Frameworks/node-webkit Helper NP.app/Contents/MacOS/node-webkit Helper NP')) {251 fs.chmodSync(path + 'Frameworks/node-webkit Helper NP.app/Contents/MacOS/node-webkit Helper NP', '555');252 } else {253 fs.chmodSync(path + 'Frameworks/nwjs Helper NP.app/Contents/MacOS/nwjs Helper NP', '555');254 }255 if (fs.existsSync(path + 'Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper')) {256 fs.chmodSync(path + 'Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper', '555');257 } else {258 fs.chmodSync(path + 'Frameworks/nwjs Helper.app/Contents/MacOS/nwjs Helper', '555');259 }260 if (fs.existsSync(path + 'MacOS/node-webkit')) {261 fs.chmodSync(path + 'MacOS/node-webkit', '555');262 } else {263 fs.chmodSync(path + 'MacOS/nwjs', '555');264 }265 });266 grunt.registerTask('createLinuxApp', 'Create linux distribution.', function (version) {267 var done = this.async();268 var childProcess = require('child_process');269 var exec = childProcess.exec;270 var path = './' + (version === 'Linux64' ? config.distLinux64 : config.distLinux32);271 exec('mkdir -p ' + path + '; cp resources/node-webkit/' + version + '/nw.pak ' + path + ' && cp resources/node-webkit/' + version + '/nw ' + path + '/node-webkit && cp resources/node-webkit/' + version + '/icudtl.dat ' + path + '/icudtl.dat', function (error, stdout, stderr) {272 var result = true;273 if (stdout) {274 grunt.log.write(stdout);275 }276 if (stderr) {277 grunt.log.write(stderr);278 }279 if (error !== null) {280 grunt.log.error(error);281 result = false;282 }283 done(result);284 });285 });286 grunt.registerTask('createWindowsApp', 'Create windows distribution.', function () {287 var done = this.async();288 var concat = require('concat-files');289 concat([290 'buildTmp/nw.exe',291 'buildTmp/app.nw'292 ], 'buildTmp/MyMD.exe', function () {293 var fs = require('fs');294 fs.unlink('buildTmp/app.nw', function (error, stdout, stderr) {295 if (stdout) {296 grunt.log.write(stdout);297 }298 if (stderr) {299 grunt.log.write(stderr);300 }301 if (error !== null) {302 grunt.log.error(error);303 done(false);304 } else {305 fs.unlink('buildTmp/nw.exe', function (error, stdout, stderr) {306 var result = true;307 if (stdout) {308 grunt.log.write(stdout);309 }310 if (stderr) {311 grunt.log.write(stderr);312 }313 if (error !== null) {314 grunt.log.error(error);315 result = false;316 }317 done(result);318 });319 }320 });321 });322 });323 grunt.registerTask('setVersion', 'Set version to all needed files', function (version) {324 var config = grunt.config.get(['config']);325 var appPath = config.app;326 var resourcesPath = config.resources;327 var mainPackageJSON = grunt.file.readJSON('package.json');328 var appPackageJSON = grunt.file.readJSON(appPath + '/package.json');329 var infoPlistTmp = grunt.file.read(resourcesPath + '/mac/Info.plist.tmp', {330 encoding: 'UTF8'331 });332 var infoPlist = grunt.template.process(infoPlistTmp, {333 data: {334 version: version335 }336 });337 mainPackageJSON.version = version;338 appPackageJSON.version = version;339 grunt.file.write('package.json', JSON.stringify(mainPackageJSON, null, 2), {340 encoding: 'UTF8'341 });342 grunt.file.write(appPath + '/package.json', JSON.stringify(appPackageJSON, null, 2), {343 encoding: 'UTF8'344 });345 grunt.file.write(resourcesPath + '/mac/Info.plist', infoPlist, {346 encoding: 'UTF8'347 });348 });349 grunt.registerTask('createPlistFile', 'set node webkit and app relevant information to a new plist file', function() {350 var metadata = grunt.file.readJSON('.yo-rc.json');351 var resourcesPath = config.resources;352 var nwExecuteable = 'nwjs';353 if (metadata.nodeWebkitVersion.indexOf('v0.8.') === 0 || metadata.nodeWebkitVersion.indexOf('v0.9.') === 0 || metadata.nodeWebkitVersion.indexOf('v0.10.') === 0 || metadata.nodeWebkitVersion.indexOf('v0.11.') === 0) {354 nwExecuteable = 'node-webkit';355 }356 var infoPlistTmp = grunt.file.read(resourcesPath + '/mac/Info.plist.tmp', {357 encoding: 'UTF8'358 });359 var infoPlist = grunt.template.process(infoPlistTmp, {360 data: {361 nwExecutableName: nwExecuteable362 }363 });364 grunt.file.write(resourcesPath + '/mac/Info.plist', infoPlist, {365 encoding: 'UTF8'366 });367 })368 grunt.registerTask('dist-linux', [369 'jshint',370 'clean:distLinux64',371 'copy:appLinux',372 'createLinuxApp:Linux64'373 ]);374 grunt.registerTask('dist-linux32', [375 'jshint',376 'clean:distLinux32',377 'copy:appLinux32',378 'createLinuxApp:Linux32'379 ]);380 grunt.registerTask('dist-win', [381 'jshint',382 'clean:distWin',383 'copy:copyWinToTmp',384 'compress:appToTmp',385 'rename:zipToApp',386 'createWindowsApp',387 'compress:finalWindowsApp'388 ]);389 grunt.registerTask('dist-mac', [390 'jshint',391 'clean:distMac64',392 'createPlistFile',393 'copy:webkit64',394 'copy:appMacos64',395 'rename:macApp64',396 'chmod64'397 ]);398 grunt.registerTask('dist-mac32', [399 'jshint',400 'clean:distMac32',401 'createPlistFile',402 'copy:webkit32',403 'copy:appMacos32',404 'rename:macApp32',405 'chmod32'406 ]);407 grunt.registerTask('check', [408 'jshint'409 ]);410 grunt.registerTask('dmg', 'Create dmg from previously created app folder in dist.', function () {411 var done = this.async();412 var createDmgCommand = 'resources/mac/package.sh "MyMD"';413 require('child_process').exec(createDmgCommand, function (error, stdout, stderr) {414 var result = true;415 if (stdout) {416 grunt.log.write(stdout);417 }418 if (stderr) {419 grunt.log.write(stderr);420 }421 if (error !== null) {422 grunt.log.error(error);423 result = false;424 }425 done(result);426 });427 });...

Full Screen

Full Screen

priv.js

Source:priv.js Github

copy

Full Screen

1/**2 * Copyright (c) 2014, 2015 Tim Kuijsten3 *4 * Permission to use, copy, modify, and/or distribute this software for any5 * purpose with or without fee is hereby granted, provided that the above6 * copyright notice and this permission notice appear in all copies.7 *8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.15 */16'use strict';17// run as a privileged user18var assert = require('assert');19var fs = require('fs');20var os = require('os');21var chroot = require('../index');22if (process.getuid() !== 0) {23 console.error('run these privileged tests as user root');24 process.exit(1);25}26// ensure pwd27process.env.PWD = '/var/empty';28assert.throws(function() { chroot(); }, /newRoot must be a string/);29assert.throws(function() { chroot('foo'); }, /user must be a string or a number/);30assert.throws(function() { chroot('foo', 'user'); }, /user not found: user/);31assert.throws(function() { chroot('foo', 'nobody'); }, /ENOENT: no such file or directory/);32assert.throws(function() { chroot('foo', 'root'); }, /new user can not have user id 0/);33assert.throws(function() { chroot('foo', 0); }, /new user can not have user id 0/);34assert.throws(function() { chroot('foo', 'nobody', 'root'); }, /new group can not have group id 0/);35assert.throws(function() { chroot('foo', 'nobody', 0); }, /new group can not have group id 0/);36// create a root owned directory that is not writable for the group or others, but37// has ancestors that fail this criteria (/tmp)38var tmpsubdir = fs.realpathSync(os.tmpdir()) + '/chroot-permission-test';39try {40 fs.mkdirSync(tmpsubdir, '0755');41} catch(err) {42 if (err.code !== 'EEXIST') {43 throw err;44 }45 // recreate to ensure permissions46 fs.rmdirSync(tmpsubdir);47 fs.mkdirSync(tmpsubdir, '0755');48}49// should complain about writable by group or others on the ancestor of tmpsubdir50assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + fs.realpathSync(os.tmpdir()) + ' owner: 0 or permissions: \\d+77$'));51// should complain about writable by group on tmpsubdir itself52fs.chmodSync(tmpsubdir, '720');53assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + tmpsubdir + ' owner: 0 or permissions: \\d+720$'));54fs.chmodSync(tmpsubdir, '730');55assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + tmpsubdir + ' owner: 0 or permissions: \\d+730$'));56fs.chmodSync(tmpsubdir, '760');57assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + tmpsubdir + ' owner: 0 or permissions: \\d+760$'));58fs.chmodSync(tmpsubdir, '770');59assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + tmpsubdir + ' owner: 0 or permissions: \\d+770$'));60// should complain about writable by others on tmpsubdir itself61fs.chmodSync(tmpsubdir, '702');62assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + tmpsubdir + ' owner: 0 or permissions: \\d+702$'));63fs.chmodSync(tmpsubdir, '703');64assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + tmpsubdir + ' owner: 0 or permissions: \\d+703$'));65fs.chmodSync(tmpsubdir, '706');66assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + tmpsubdir + ' owner: 0 or permissions: \\d+706$'));67fs.chmodSync(tmpsubdir, '707');68assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + tmpsubdir + ' owner: 0 or permissions: \\d+707$'));69// should complain about writable for both group and others on tmpsubdir itself70fs.chmodSync(tmpsubdir, '773');71assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + tmpsubdir + ' owner: 0 or permissions: \\d+773$'));72// restore permissions73fs.chmodSync(tmpsubdir, '755');74// should complain about owner not being root75fs.chownSync(tmpsubdir, 1, 1);76assert.throws(function() { chroot(tmpsubdir, 'nobody'); }, new RegExp('^Error: bad chroot dir ' + tmpsubdir + ' owner: 1 or permissions: \\d+755$'));77assert.doesNotThrow(function() { chroot('/var/empty', 'nobody'); });78assert.notStrictEqual(process.getuid(), 0);79assert.notStrictEqual(process.getgid(), 0);80assert.equal(~process.getgroups().indexOf(0), false); // should not contain a root group81assert.equal(process.cwd(), '/');82assert.equal(process.env.PWD, '/');...

Full Screen

Full Screen

fs.chmod.spec.js

Source:fs.chmod.spec.js Github

copy

Full Screen

...31 });32 });33 it('should be an error when the path is invalid', function(done){34 var fs = util.fs();35 fs.chmod('/invalid_path', 0o444, function(err){36 expect(err).to.exist;37 expect(err.code).to.equal('ENOENT');38 done();39 });40 });41 it('should error if mode value is a non-numeric string', function(done) {42 var fs = util.fs();43 fs.mkdir('/dir', function(err) {44 if(err) throw err;45 46 fs.chmod('/dir', 'mode', function(err) {47 expect(err).to.exist;48 expect(err.code).to.equal('EINVAL');49 done();50 });51 });52 });53 it('should error if mode value is null', function(done) {54 var fs = util.fs();55 fs.mkdir('/dir', function(err) {56 if(err) throw err;57 58 fs.chmod('/dir', 'null', function(err) {59 expect(err).to.exist;60 expect(err.code).to.equal('EINVAL');61 done();62 });63 });64 });65 it('should error if mode value is non-integer number', function(done) {66 var fs = util.fs();67 fs.mkdir('/dir', function(err) {68 if(err) throw err;69 70 fs.chmod('/dir', 3.14, function(err) {71 expect(err).to.exist;72 expect(err.code).to.equal('EINVAL');73 done();74 });75 });76 });77 it('should error if mode value is non-integer number', function(done) {78 var fs = util.fs();79 fs.mkdir('/dir', function(err) {80 if(err) throw err;81 82 fs.chmod('/dir', 3.14, function(err) {83 expect(err).to.exist;84 expect(err.code).to.equal('EINVAL');85 done();86 });87 });88 });89 it('should allow octal strings for mode value', function(done) {90 var fs = util.fs();91 fs.mkdir('/dir', function(err) {92 if(err) throw err;93 94 fs.chmod('/dir', '777', function(err) {95 if(err) throw err;96 fs.stat('/dir/', function(err, stats) {97 if(err) throw err;98 expect(stats.mode & 0o777).to.equal(0o777);99 done();100 });101 });102 });103 });104 it('should allow for updating mode of a given file', function(done) {105 var fs = util.fs();106 fs.open('/file', 'w', function(err, fd) {107 if(err) throw err;108 fs.fchmod(fd, 0o777, function(err) {109 if(err) throw err;110 fs.fstat(fd, function(err, stats) {111 if(err) throw err;112 expect(stats.mode & 0o777).to.equal(0o777);113 fs.close(fd, function(err) {114 if(err) throw err;115 116 fs.chmod('/file', 0o444, function(err) {117 if(err) throw err;118 119 fs.stat('/file', function(err, stats) {120 if(err) throw err;121 expect(stats.mode & 0o444).to.equal(0o444);122 done();123 });124 });125 });126 });127 });128 });129 });130});...

Full Screen

Full Screen

compressktx.js

Source:compressktx.js Github

copy

Full Screen

1const path = require('path');2const fs = require('fs');3const child_process = require('child_process');4const compressorPath = path.join(global.HYDRA_PATH, 'node_modules', 'texture-compressor', 'lib', 'index.js');5const Jimp = require(path.join(global.HYDRA_PATH, 'node_modules', 'jimp'));6const rootPath = path.join(global.HYDRA_PATH, '..', '..');7Math.isPowerOf2 = function(w, h) {8 let test = value => (value & (value - 1)) == 0;9 return test(w) && test(h);10}11Math.roundPowerOf2 = function(value) {12 return Math.pow(2, Math.round(Math.log(value) / Math.LN2));13}14function createPromise() {15 let temp_resolve, temp_reject;16 const promise = new Promise((resolve, reject) => {17 temp_resolve = resolve;18 temp_reject = reject;19 });20 promise.resolve = temp_resolve;21 promise.reject = temp_reject;22 return promise;23}24function exec(cmd) {25 let promise = createPromise();26 child_process.exec(cmd, (e, d) => {27 if (!e) promise.resolve();28 else promise.reject(e);29 });30 return promise;31}32module.exports = async function(project, {src}) {33 if (!src) throw 'Error';34 let imagePath = path.join.apply(null, [rootPath, project, 'HTML', ...src.split('/')]);35 let folderPath = imagePath.split('.')[0];36 let fileName = imagePath.split(path.sep);37 fileName = fileName[fileName.length-1];38 if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath);39 let img = await Jimp.read(imagePath);40 let {width, height} = img.bitmap;41 if (!Math.isPowerOf2(width, height)) {42 width = height = Math.roundPowerOf2(Math.max(width, height));43 }44 await img.resize(width, height);45 await img.flip(false, true);46 await img.write(path.join(folderPath, fileName));47 let imgPath = path.join(folderPath, fileName);48 let imgOut = path.join(folderPath, fileName.split('.')[0]);49 let mipmap = fileName.includes('mipmap') ? '-m' : '';50 try {51 if (imagePath.includes('png')) {52 await Promise.all([53 exec(`node ${compressorPath} -i ${imgPath} -o ${imgOut}-dxt.ktx -t s3tc -c dxt5 ${mipmap}`),54 exec(`node ${compressorPath} -i ${imgPath} -o ${imgOut}-astc.ktx -t astc -c astc -b 8x8 ${mipmap}`),55 exec(`node ${compressorPath} -i ${imgPath} -o ${imgOut}-pvrtc.ktx -t pvr -c pvrtc1 -b 4 -a ${mipmap}`)56 ]);57 } else {58 await Promise.all([59 exec(`node ${compressorPath} -i ${imgPath} -o ${imgOut}-dxt.ktx -t s3tc -c dxt1 ${mipmap}`),60 exec(`node ${compressorPath} -i ${imgPath} -o ${imgOut}-astc.ktx -t etc -c etc1 ${mipmap}`),61 exec(`node ${compressorPath} -i ${imgPath} -o ${imgOut}-pvrtc.ktx -t pvr -c pvrtc1 -b 4 ${mipmap}`),62 ]);63 }64 } catch(e) {65 throw e;66 }67 await Promise.all([68 exec(`gzip -9 -k ${imgOut}-dxt.ktx`),69 exec(`gzip -9 -k ${imgOut}-astc.ktx`),70 exec(`gzip -9 -k ${imgOut}-pvrtc.ktx`)71 ]);72 try {73 fs.unlinkSync(imgPath);74 fs.chmodSync(folderPath, '777');75 fs.chmodSync(imgOut + '-dxt.ktx', '777');76 fs.chmodSync(imgOut + '-astc.ktx', '777');77 fs.chmodSync(imgOut + '-pvrtc.ktx', '777');78 fs.chmodSync(imgOut + '-dxt.ktx.gz', '777');79 fs.chmodSync(imgOut + '-astc.ktx.gz', '777');80 fs.chmodSync(imgOut + '-pvrtc.ktx.gz', '777');81 } catch(e) {82 }83 return 'OK';...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1'use strict';2var util = require('util');3var path = require('path');4var yeoman = require('yeoman-generator');5var yosay = require('yosay');6var fs = require('fs');7var BuildpackGenerator = yeoman.generators.Base.extend({8 initializing: function () {9 this.pkg = require('../package.json');10 },11 prompting: function () {12 var done = this.async();13 // try to guess name14 this.projectname = path.basename(process.cwd());15 this.name = this.appname.replace('heroku', '').replace('buildpack', '').replace(/\s/g, '');16 // replace it with a short and sweet description of your generator17 this.log(yosay('Tell me about your custom Heroku buildpack.'));18 var prompts = [19 {20 type: 'text',21 name: 'name',22 message: 'Buildpack for',23 default: this.name24 },25 {26 type: 'text',27 name: 'username',28 message: 'Would you mind telling me your username on GitHub',29 default: 'someuser'30 }31 ];32 this.prompt(prompts, function (props) {33 this.username = props.username;34 this.name = props.name || this.name;35 this.url = 'https://github.com/'+this.username+'/'+this.projectname;36 done();37 }.bind(this));38 },39 writing: {40 app: function () {41 this.dest.mkdir('bin');42 this.template('bin/compile');43 this.template('bin/detect');44 this.template('bin/release');45 this.template('bin/test');46 this.template('bin/utils');47 this.directory('test', 'test');48 this.directory('vendor', 'vendor');49 },50 projectfiles: function () {51 this.template('README.md');52 this.src.copy('.travis.yml', '.travis.yml');53 this.src.copy('.drone.yml', '.drone.yml');54 this.template('test-in-docker');55 this.template('Dockerfile');56 this.src.copy('.dockerignore', '.dockerignore');57 }58 },59 end: function () {60 // temporary fix until https://github.com/SBoudrias/file-utils/issues/5 is fixed in yeoman61 fs.chmodSync(path.join(this.destinationRoot(), 'bin/compile'), '755');62 fs.chmodSync(path.join(this.destinationRoot(), 'bin/detect'), '755');63 fs.chmodSync(path.join(this.destinationRoot(), 'bin/release'), '755');64 fs.chmodSync(path.join(this.destinationRoot(), 'bin/test'), '755');65 fs.chmodSync(path.join(this.destinationRoot(), 'bin/utils'), '755');66 fs.chmodSync(path.join(this.destinationRoot(), 'test-in-docker'), '755');67 }68});...

Full Screen

Full Screen

VirtualFSSingle.js

Source:VirtualFSSingle.js Github

copy

Full Screen

1//@flow2/** @module VirtualFSSingleton */3import VirtualFS from './VirtualFS';4import { DeviceManager } from './Devices.js';5import constants from './constants.js';6import nullDev from './Devices/null.js';7import zeroDev from './Devices/zero.js';8import fullDev from './Devices/full.js';9import randomDev from './Devices/random.js';10import ttyDev from './Devices/tty.js';11const devMgr = new DeviceManager;12devMgr.registerChr(nullDev, 1, 3);13devMgr.registerChr(zeroDev, 1, 5);14devMgr.registerChr(fullDev, 1, 7);15devMgr.registerChr(randomDev, 1, 8);16devMgr.registerChr(randomDev, 1, 9);17devMgr.registerChr(ttyDev, 4, 0);18devMgr.registerChr(ttyDev, 5, 0);19devMgr.registerChr(ttyDev, 5, 1);20const fs = new VirtualFS(undefined, undefined, devMgr);21fs.mkdirSync('/dev');22fs.chmodSync('/dev', 0o775);23fs.mknodSync('/dev/null', constants.S_IFCHR, 1, 3);24fs.mknodSync('/dev/zero', constants.S_IFCHR, 1, 5);25fs.mknodSync('/dev/full', constants.S_IFCHR, 1, 7);26fs.mknodSync('/dev/random', constants.S_IFCHR, 1, 8);27fs.mknodSync('/dev/urandom', constants.S_IFCHR, 1, 9);28fs.chmodSync('/dev/null', 0o666);29fs.chmodSync('/dev/zero', 0o666);30fs.chmodSync('/dev/full', 0o666);31fs.chmodSync('/dev/random', 0o666);32fs.chmodSync('/dev/urandom', 0o666);33// tty0 points to the currently active virtual console (on linux this is usually tty1 or tty7)34// tty points to the currently active console (physical, virtual or pseudo)35// console points to the system console (it defaults to tty0)36// refer to the tty character device to understand its implementation37fs.mknodSync('/dev/tty0', constants.S_IFCHR, 4, 0);38fs.mknodSync('/dev/tty', constants.S_IFCHR, 5, 0);39fs.mknodSync('/dev/console', constants.S_IFCHR, 5, 1);40fs.chmodSync('/dev/tty0', 0o600);41fs.chmodSync('/dev/tty', 0o666);42fs.chmodSync('/dev/console', 0o600);43fs.mkdirSync('/tmp');44fs.chmodSync('/tmp', 0o777);45fs.mkdirSync('/root');46fs.chmodSync('/root', 0o700);...

Full Screen

Full Screen

chmodr.js

Source:chmodr.js Github

copy

Full Screen

...9 if (stats.isSymbolicLink())10 return cb()11 if (stats.isDirectory())12 return chmodrDir(p, mode, cb)13 return fs.chmod(p, mode, cb)14 })15}16function chmodrDir (p, mode, cb) {17 fs.readdir(p, function (er, children) {18 if (er)19 return cb(er)20 if (!children.length)21 return fs.chmod(p, dirMode(mode), cb)22 var len = children.length23 var errState = null24 children.forEach(function (child) {25 chmodr(path.resolve(p, child), mode, then)26 })27 // return first error, but not until all are finished,28 // so we don't keep performing FS operations after the cb29 function then (er) {30 len = len - 131 if (er && !errState)32 errState = er33 if (len === 0) {34 if (errState)35 return cb(errState)36 else37 return fs.chmod(p, dirMode(mode), cb)38 }39 }40 })41}42function chmodrSync (p, mode) {43 var stats = fs.lstatSync(p)44 if (stats.isSymbolicLink())45 return46 if (stats.isDirectory())47 return chmodrDirSync(p, mode)48 else49 return fs.chmodSync(p, mode)50}51function chmodrDirSync (p, mode) {...

Full Screen

Full Screen

fs-chmod-shell.js

Source:fs-chmod-shell.js Github

copy

Full Screen

1const { app } = require('electron');2const path = require('path');3const fsChmod = require('./fs-chmod');4function fsChmodShell() {5 fsChmod(path.join(pathRuntime, 'scripts'), 0o711);6}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2 it('test', () => {3 cy.readFile('path/to/file').then((file) => {4 cy.writeFile('path/to/file', file, {5 });6 });7 });8});

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.readFile('path/to/file').then((content) => {2 cy.writeFile('path/to/file', content, 'utf8').then(() => {3 cy.exec('chmod 777 path/to/file')4 })5})6cy.readFile('path/to/file').then((content) => {7 cy.writeFile('path/to/file', content, 'utf8').then(() => {8 cy.exec('chmod 777 path/to/file')9 })10})11cy.readFile('path/to/file').then((content) => {12 cy.writeFile('path/to/file', content, 'utf8').then(() => {13 cy.exec('chmod 777 path/to/file')14 })15})16cy.readFile('path/to/file').then((content) => {17 cy.writeFile('path/to/file', content, 'utf8').then(() => {18 cy.exec('chmod 777 path/to/file')19 })20})21cy.readFile('path/to/file').then((content) => {22 cy.writeFile('path/to/file', content, 'utf8').then(() => {23 cy.exec('chmod 777 path/to/file')24 })25})26cy.readFile('path/to/file').then((content) => {27 cy.writeFile('path/to/file', content, 'utf8').then(() => {28 cy.exec('chmod 777 path/to/file')29 })30})31cy.readFile('path/to/file').then((content) => {32 cy.writeFile('path/to/file', content, 'utf8').then(() => {33 cy.exec('chmod 777 path/to/file')34 })35})36cy.readFile('path/to/file').then((content) => {37 cy.writeFile('path/to/file', content, 'utf8').then(() => {38 cy.exec('chmod 777 path/to/file')39 })40})41cy.readFile('

Full Screen

Using AI Code Generation

copy

Full Screen

1const fs = require('fs');2const path = 'cypress/fixtures/test.json';3fs.chmod(patt, 777, function(err) {4 if (err) {5 console.log(err);6 } else {7 console.log('Po mission changcdhto 777');8 }9});10describe('Test', function() {11 it('Test', function() {12 cy.fixturn('test').then(function(data) {13 g cy.log(data);14 });15 });16});

Full Screen

Using AI Code Generation

copy

Full Screen

1const fs = require('fs');2const path = 'cypress/fixtures/test.json';3fs.chmod(path, 777, function(err) {4 if (err) {5 console.log(err);6 } else {

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2fs.chmod('test.txt', 777, (err) => {3 if (err) throw err;4 console.log('Changed file permissions!');5});6var fs = require('fs');7fs.chown('test.txt', 1000, 1000, (err) => {8 if (err) throw err;9 console.log('Changed file ownership!');10});11var fs = require('fs');12fs.chownSync('test.txt', 1000, 1000);13console.log('Changed file ownership!');14var fs = require('fs');15fs.open('test.txt', 'w', (err, fd) => {16 if (err) throw err;17 console.log('File opened successfully!');18 fs.close(fd, (err) => {19 if (err) throw err;20 console.log('File closed successfully!');21 });22});23var fs = require('fs');24var fd = fs.openSync('test.txt', 'w');25console.log('File opened successfully!');26fs.closeSync(fd);27console.log('File closed successfully!');28var fs = require('fs');29console.log('O_RDONLY: ' + fs.constants.O_RDONLY);30console.log('O_WRONLY: ' + fs.constants.O_WRONLY);31console.log('O_RDWR: ' + fs.constants.O_RDWR);32console.log('O_CREAT: ' + fs.constants.O_CREAT);33console.log('O_EXCL: ' + fs.constants.O_EXCL);34console.log('O_NOCTTY: ' + fs.constants.O_NOCTTY);35console.log('O_TRUNC: ' + fs.constants.O_TRUNC);36console.log('O_APPEND: '

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test to verify the file permissions', () => {2 it('Verify the file permissions', () => {3 cy.get('a').contains('Cypress').click()4 cy.get('a').contains('fs').click()5 cy.get('a').contains('fs.chmod').click()6 cy.get('a').contains('fs.chmod.js').click()7 cy.get('a').contains('fs.chmod.js').invoke('attr', 'href').then(href => {8 cy.readFile(href).then((content) => {9 cy.writeFile('test.js', content)10 })11 })12 cy.readFile('test.js', 'utf8').then((content) => {13 cy.writeFile('test.js', content, { encoding: 'utf8' })14 cy.log(content)15 })16 cy.writeFile('test.js', 'var fs = require("fs");fs.chmod("test.js", 0o777, function (err) {if (err) {return console.error(err);}console.log("File permissions changed!");});', { encoding: 'utf8' })17 cy.exec('node test.js')18 cy.readFile('test.js', 'utf8').then((content) => {19 cy.writeFile('test.js', content, { encoding: 'utf8' })20 cy.log(content)21 })22 })23})24describe('Test to verify the file ownership', () => {25 it('Verify the file ownership', () => {26 cy.get('a').contains('Cypress').click()27 cy.get('a').contains('fs').click()28 cy.get('a').contains('fsle.log('Permission changed to 777');29 }30});31describe('Test', function() {32 it('Test', function() {33 cy.fixture('test').then(function(data) {34 cy.log(data);35 });36 });37});

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test to verify the file permissions', () => {2 it('Verify the file permissions', () => {3 cy.get('a').contains('Cypress').click()4 cy.get('a').contains('fs').click()5 cy.get('a').contains('fs.chmod').click()6 cy.get('a').contains('fs.chmod.js').click()7 cy.get('a').contains('fs.chmod.js').invoke('attr', 'href').then(href => {8 cy.readFile(href).then((content) => {9 cy.writeFile('test.js', content)10 })11 })12 cy.readFile('test.js', 'utf8').then((content) => {13 cy.writeFile('test.js', content, { encoding: 'utf8' })14 cy.log(content)15 })16 cy.writeFile('test.js', 'var fs = require("fs");fs.chmod("test.js", 0o777, function (err) {if (err) {return console.error(err);}console.log("File permissions changed!");});', { encoding: 'utf8' })17 cy.exec('node test.js')18 cy.readFile('test.js', 'utf8').then((content) => {19 cy.writeFile('test.js', content, { encoding: 'utf8' })20 cy.log(content)21 })22 })23})24describe('Test to verify the file ownership', () => {25 it('Verify the file ownership', () => {26 cy.get('a').contains('Cypress').click()27 cy.get('a').contains('fs').click()28 cy.get('a').contains('fs

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