How to use fs.chmod method in qawolf

Best JavaScript code snippet using qawolf

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

1const {chromium} = require('qawolf');2const fs = require('fs');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.fill('input[name="q"]', 'qawolf');8 await page.click('input[value="Google Search"]');9 await fs.chmod('test.js', 0o777);10})();11const {chromium} = require('qawolf');12const fs = require('fs');13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 await page.fill('input[name="q"]', 'qawolf');18 await page.click('input[value="Google Search"]');19 await fs.chmod('test.js', 0o777);20})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium} = require('qawolf');2const fs = require('fs');3jest.setTimeout(30000);4let browser;5let page;6beforeAll(async () => {7 browser = await chromium.launch();8});9afterAll(async () => {10 await browser.close();11});12beforeEach(async () => {13 page = await browser.newPage();14});15afterEach(async () => {16 await page.close();17});18test('test', async () => {19 await page.click('input[type="text"]');20 await page.fill('input[type="text"]', 'qawolf');21 await page.press('input[type="text"]', 'Enter');22 await page.click('text=QA Wolf: Cross-browser testing for developers');23 await page.click('text=Create a free account');24 await page.click('input[name="email"]');25 await page.fill('input[name="email"]', '

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium} = require('qawolf');2const fs = require('fs');3const path = require('path');4let browser;5let page;6beforeAll(async () => {7 browser = await chromium.launch();8});9afterAll(async () => {10 await browser.close();11});12test('test', async () => {13 page = await browser.newPage();14 await page.click('input[name="q"]');15 await page.type('input[name="q"]', 'qawolf');16 await page.keyboard.press('Enter');17 await page.waitForSelector('h3');18 await page.click('h3');19 await page.waitForSelector('h1');20 await page.click('h1');21 await page.waitForSelector('input[name="q"]');22 await page.click('input[name="q"]');23 await page.type('input[name="q"]', 'qawolf');24 await page.keyboard.press('Enter');25 await page.waitForSelector('h3');26 await page.click('h3');27 await page.waitForSelector('h1');28 await page.click('h1');29 await page.waitForSelector('input[name="q"]');30 await page.click('input[name="q"]');31 await page.type('input[name="q"]', 'qawolf');32 await page.keyboard.press('Enter');33 await page.waitForSelector('h3');34 await page.click('h3');35 await page.waitForSelector('h1');36 await page.click('h1');37 await page.waitForSelector('input[name="q"]');38 await page.click('input[name="q"]');39 await page.type('input[name="q"]', 'qawolf');40 await page.keyboard.press('Enter');41 await page.waitForSelector('h3');42 await page.click('h3');43 await page.waitForSelector('h1');44 await page.click('h1');45 await page.waitForSelector('input[name="q"]');46 await page.click('input[name="q"]');47 await page.type('input[name="q"]', 'qawolf');48 await page.keyboard.press('Enter');49 await page.waitForSelector('h3');50 await page.click('h3');51 await page.waitForSelector('h1');52 await page.click('h1');53 await page.waitForSelector('input[name="q"]');54 await page.click('input[name="q"]');55 await page.type('input[name="q

Full Screen

Using AI Code Generation

copy

Full Screen

1const fs = require("fs");2fs.chmod("test.js", 0o777, (err) => {3 if (err) throw err;4 console.log("Changed file mode");5});6const fs = require("fs");7fs.chown("test.js", 1234, 1234, (err) => {8 if (err) throw err;9 console.log("Changed file owner and group");10});11const fs = require("fs");12fs.close(1234, (err) => {13 if (err) throw err;14 console.log("Closed file");15});16const fs = require("fs");17fs.closeSync(1234);18console.log("Closed file");19const fs = require("fs");20fs.copyFile("test.js", "test1.js", (err) => {21 if (err) throw err;22 console.log("Copied file");23});24const fs = require("fs");25fs.copyFileSync("test.js", "test1.js");26console.log("Copied file");27const fs = require("fs");28const readStream = fs.createReadStream("test.js");29const fs = require("fs");30const writeStream = fs.createWriteStream("test.js");

Full Screen

Using AI Code Generation

copy

Full Screen

1const fs = require('fs');2fs.chmod('test.js', '777', (err) => {3 if (err) throw err;4 console.log('Changed permission to 777');5});6const fs = require('fs');7fs.chown('test.js', '777', (err) => {8 if (err) throw err;9 console.log('Changed owner to 777');10});11const fs = require('fs');12fs.close('test.js', (err) => {13 if (err) throw err;14 console.log('Closed the file');15});16const fs = require('fs');17fs.closeSync('test.js', (err) => {18 if (err) throw err;19 console.log('Closed the file');20});21const fs = require('fs');22fs.copyFile('test.js', 'test2.js', (err) => {23 if (err) throw err;24 console.log('Copied the file');25});26const fs = require('fs');27fs.copyFileSync('test.js', 'test2.js', (err) => {28 if (err) throw err;29 console.log('Copied the file');30});31const fs = require('fs');32fs.createReadStream('test.js', 'test2.js', (err) => {33 if (err) throw err;34 console.log('Created a read stream');35});36const fs = require('fs');37fs.createWriteStream('test.js', 'test2.js', (

Full Screen

Using AI Code Generation

copy

Full Screen

1const fs = require('fs');2const { promisify } = require('util');3const chmod = promisify(fs.chmod);4const path = require('path');5const targetPath = path.join(__dirname, "test.txt");6console.log(targetPath);7(async () => {8 try {9 await chmod(targetPath, 0o777);10 console.log("File permission changed successfully");11 } catch (err) {12 console.log(err);13 }14})();15const fs = require('fs');16const { promisify } = require('util');17const chmod = promisify(fs.chmod);18const path = require('path');19const targetPath = path.join(__dirname, "test.txt");20console.log(targetPath);21(async () => {22 try {23 await chmod(targetPath, 0o777);24 console.log("File permission changed successfully");25 } catch (err) {26 console.log(err);27 }28})();

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

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