fs.writeFile(filePath, contents, function(err) { if(err) { return done(err); } fs.chmod(filePath, parseInt("0777", 8), function(err) { done(null, filePath); }); });
function installRevo(path) { // log.msg('install revo') var startFilename = path + '/' + util.shortFilename(path); fs.writeFileSync(startFilename, 'npm start'); fs.chmod(startFilename, '0755'); try { fs.mkdirSync(path + '/container'); } catch (err) { // dir already exists - ignore err } var runFilename = path + '/container/run'; fs.writeFileSync(runFilename, '#!/usr/bin/env node\nvar container=require("./container");\ncontainer.init();\ncontainer.start();'); fs.chmod(runFilename, '0755'); installFile('container.js', path + '/container'); installFile('helpers.js', path + '/container'); }
exports.chmodSyncRecursive = function(sourceDir, filemode) { var files = fs.readdirSync(sourceDir); for(var i = 0; i < files.length; i++) { var currFile = fs.lstatSync(sourceDir + "/" + files[i]); if(currFile.isDirectory()) { /* ...and recursion this thing right on back. */ exports.chmodSyncRecursive(sourceDir + "/" + files[i], filemode); } else { /* At this point, we've hit a file actually worth copying... so copy it on over. */ fs.chmod(sourceDir + "/" + files[i], filemode); } } /* Finally, chmod the parent directory */ fs.chmod(sourceDir, filemode); };
return new Promise((resolve, reject) => { fs.chmod(path, mode, (err, result) => { if (err == null) { resolve(result); } else { reject(err); } }); });
fs.writeFile(post, postscript, 'utf8', function(err) { if (err) { err_cb(err); return; } fs.chmod(post, 493, function(err) { // 0755 === 493 err_cb(err); }); });
enable: function(path, callback) { if (self.options.disabledFileKey) { return fs.rename(uploadsPath + utils.getDisabledPath(path, self.options.disabledFileKey), uploadsPath + path, callback); } else { // World readable, owner writable. Reasonable since // web accessible files are world readable in that // sense regardless return fs.chmod(uploadsPath + path, self.getEnablePermissions(), callback); } },
return new Promise(function (resolve, reject) { fs.chmod(filename, mode, function (err) { if (err) { reject(err); } else { resolve(undefined); } }); });
mkdirp(filePath, function (err) { if (err) { logError(err); } else { fs.chmod(filePath, mode, function () { execWrite(file, data, _callback); }) } });
return new Promise(function (resolve, reject) { if (config.get('server').hasOwnProperty('socket')) { socketConfig = config.get('server').socket; if (_.isString(socketConfig)) { socketValues.path = socketConfig; } else if (_.isObject(socketConfig)) { socketValues.path = socketConfig.path || socketValues.path; socketValues.permissions = socketConfig.permissions || socketValues.permissions; } // Make sure the socket is gone before trying to create another try { fs.unlinkSync(socketValues.path); } catch (e) { // We can ignore this. } self.httpServer = rootApp.listen(socketValues.path); fs.chmod(socketValues.path, socketValues.permissions); config.set('server:socket', socketValues); } else { self.httpServer = rootApp.listen( config.get('server').port, config.get('server').host ); } self.httpServer.on('error', function (error) { var ghostError; if (error.errno === 'EADDRINUSE') { ghostError = new errors.GhostError({ message: i18n.t('errors.httpServer.addressInUse.error'), context: i18n.t('errors.httpServer.addressInUse.context', {port: config.get('server').port}), help: i18n.t('errors.httpServer.addressInUse.help') }); } else { ghostError = new errors.GhostError({ message: i18n.t('errors.httpServer.otherError.error', {errorNumber: error.errno}), context: i18n.t('errors.httpServer.otherError.context'), help: i18n.t('errors.httpServer.otherError.help') }); } reject(ghostError); }); self.httpServer.on('connection', self.connection.bind(self)); self.httpServer.on('listening', function () { debug('...Started'); self.logStartMessages(); resolve(self); }); });
fs.writeFile( options.dest, f, function( err ){ if( err ){ p.reject( err ); } fs.chmod( options.dest, 493, function( e ){ if( e ){ p.reject( e ); } p.resolve(); }); });
fs.stat(writePath, function(err, st) { if (err) { return complete(err); } // octal 7777 = decimal 4095 var currentMode = (st.mode & 4095); if (currentMode === file.stat.mode) { return complete(); } fs.chmod(writePath, file.stat.mode, complete); });
fs.stat(fp, function(err, st) { if (err) { return complete(err); } var currentMode = (st.mode & parseInt('0777', 8)); var expectedMode = (file.stat.mode & parseInt('0777', 8)); if (currentMode === expectedMode) { return complete(); } fs.chmod(fp, expectedMode, complete); });
getNodeModules(function (path, stats) { nodeModulesDir = path; nodeModulesStat = new mode(stats); if (nodeModulesStat.toString() != 'drwxr-xr-x'){ fs.chmod(nodeModulesDir, parseInt('0755',8), function (){ console.log('Set '+nodeModulesDir+' to 755.'); }); } chownr(nodeModulesDir, Number(userId), 80, function () { console.log('Set ownership of '+nodeModulesDir+' to '+program.user+':admin'); }); });
fs.stat(bin, function (err, stat) { if (err) { return callback(new Error("Couldn't read sc permissions: " + err.message)); } if (stat.mode.toString(8) !== "100755") { fs.chmod(bin, 0o755, function (err) { if (err) { return callback(new Error("Couldn't set permissions: " + err.message)); } callback(null, bin); }); } else { callback(null, bin); } });
File.prototype.setReadOnly = function (cb){ if (cb) cb = cb.bind (this); if (!canWriteSM (this._usablePath)){ if (cb) cb (Error.get (Error.SECURITY_WRITE, { path: this._usablePath }), false); return; } FS.chmod (this._usablePath, "444", function (error){ cb (error, !error); }); };
function chmodDataDirectory(err) { if (err) { return next(err); } debug("Creating an instance: chmodDataDirectory", technicalName); fs.chmod( cfg.dataInstancesPath + "/" + technicalName + "/data/", 0o777, createConfigFile ); }
NX.fs.chmod = function(path, mode, callback) { if(NX.isDefined(callback) && NX.isFunction(callback)) { fs.chmod(path, mode, callback); return; } var deferred = new NX.util.Deferred(); fs.chmod(path, mode, function(e) { if(NX.isNull(e)) { deferred.call(); } else { deferred.fail(e); } }); return deferred; };
File.prototype.setPermissions = function (permissions, cb){ if (cb) cb = cb.bind (this); if (!canWriteSM (this._usablePath)){ if (cb) cb (Error.get (Error.SECURITY_WRITE, { path: this._usablePath }), false); return; } FS.chmod (this._usablePath, permissions, function (error){ if (cb) cb (error, !error); }); };
fs.writeFile(hookPath, hook, function (err) { if (err) return cb(err) fs.chmod(hookPath, '0777', function (err) { if (err) return cb(err) console.log('excuting github webhook for ' + appid + '...') var child = spawn('bash', [hookPath]) child.stdout.pipe(process.stdout) child.stderr.pipe(process.stderr) child.on('exit', function (code) { fs.unlink(hookPath, cb) }) }) })
fs.writeFile(config.opt.proxy_table_file, JSON.stringify(proxy_map), function(err) { if (err) { cb(err); } else { fs.chmod(config.opt.proxy_table_file, '0666', function(err) { if (err) { cb(err); } else { cb(); } }); } });
tmpFileStream.close(function(error) { if (error) { return callback(error); } fs.chmod(tmpPath, '700', function(error) { if (error) { return callback(error); } callback(null, tmpPath); }); });
exports.chmod = function(path, mode) { var subject = new Rx.AsyncSubject(), handler = function (err) { if (err) { subject.onError(err); } else { subject.onNext(); subject.onCompleted(); } }; fs.chmod(path, mode, handler); return subject; };
// update the file permissions to be able to execute dlv function updatePermission(path) { if (!path) { reject("Failed to find delve executable \"dlv\" in your GOPATH"); return; } fs.chmod(path, 0o777, (err) => { if (err) { reject(err); return; } resolve(path); }); }
fs.stat(filePathReadTest, function(err, fileStat) { if (err) { done(err); } else { var fileMode = parseInt(fileStat.mode.toString(8), 10).toString().substr(-3); if (fileMode === '600' || fileMode === '400') { done(); } else { fs.chmod(filePathReadTest, '0600', function(err2) { done(err2); }); } } });
fs.writeFile(filepath,script,function(err){ if (err) return me.emit('error', err); fs.chmod(filepath,'755',function(_err){ if (_err) return me.emit('error', _err); var cmd = 'systemctl daemon-reload'; console.log('Running %s...', cmd); exec(cmd,function(err){ if (err) return me.emit('error', err); me.emit('install'); }); }) });
module.exports = function() { var config = this.data; var done = this.async(); fs.chmod(phantomjs, 755, function(err) { spawn({ cmd: phantomjs, args: ["--version"] }, function(error, result, code) { checkVersion(error, result, code); run(config, done); }); }); };
helper.runInTransaction(agent, function(trans) { fs.chmod(name, '0777', function(err) { t.equal(err, null, 'should not error') helper.unloadAgent(agent) t.equal((fs.statSync(name).mode & 0x1FF).toString(8), '777') verifySegments(t, agent, NAMES.FS.PREFIX + 'chmod') trans.end() t.ok( checkMetric(['chmod'], agent, trans.name), 'metric should exist after transaction end' ) }) })
exec(cmd, function(err, stdout, stderr) { if (err) { return next(err); } fs.chmod( cfg.dataInstancesPath + "/" + technicalName + "/data/", 0o777, function() { return res .status(200) .send("Instance technicalName created"); } ); });
mkdirp(dir, function (err) { if (err) { console.error(socket('omk-atlas.js: Had trouble making the deployments dir: ' + dir)); return; } statusUtility.update('', '', {initialized: true}); console.log('omk-atlas.js: Successfully created deployment dir: ' + dir); fs.chmod(dir, parseInt('0777', 8), function () { // Write manifest var jsonFileName = dir + '/fp.geojson'; var json = JSON.stringify(atlasGeoJSON, null, 2); fs.writeFile(jsonFileName, json, function (err) { if (err) { statusUtility.update('', '', {error: true}); notifySocket(socket, 'omk-atlas.js: Had trouble writing fp.geojson. ' + dir); console.error('omk-atlas.js: Had trouble writing fp.geojson. ' + dir); return; } extractOsmXml(dir, atlasGeoJSON, socket); renderPosmCartoMBTiles(dir, atlasGeoJSON, socket); if (typeof aoiDir === 'string') { copyAOIMBTilesToAtlasMBTiles(aoiDir, dir, atlasGeoJSON, socket); } }); // Create manifest.json // We don't have to wait on getting a manifest.json... var properties = atlasGeoJSON.features[0].properties; var urlArr = properties.url.split('/'); var slug = urlArr[urlArr.length - 1]; var manifest = { title: properties.title, name: slug, description: properties.description }; fs.writeFile(dir + '/manifest.json', JSON.stringify(manifest, null, 2), function (err) { if (err) { if (socket) { statusUtility.update('', '', {error: true}); notifySocket(socket, 'omk-atlas.js: Had trouble writing manifest.json. ' + dir); } console.error('omk-atlas.js: Had trouble writing manifest.json. ' + dir); } }); }); });
fs.writeFile(config.opt.proxy_table_file, JSON.stringify(proxy_map.router), function (err) { if (err) { console.log('PTABLE WRITE ERROR: ' + err); cb(err); } else { fs.chmod(config.opt.proxy_table_file, '0666', function (err) { if (err) { console.log('PTABLE CHMOD ERROR: ' + err); cb(err); } else { cb(); } }); } });