Beispiel #1
0
				mkdirp(config.cssDir, function(err) {
					if(err) {
						reject(err);
					}

					fs.appendFile(config.cssDir + '/' + config.cssFile, css.substring(css.indexOf('*/') + 3), resolve);
				});
Beispiel #2
0
	function appendToFile(newTextToWrite){
		fs.appendFile(file, newTextToWrite, function(err){
			if(err) console.log(err);

			console.log( 'Changelog has been updated with: ' + clc.blue.bgWhite(newTextToWrite) );
		});
	};
export default async function writeRedirectsFile(pluginData, redirects) {
  const { publicFolder } = pluginData

  if (!redirects.length) return null

  const FILE_PATH = publicFolder(`_redirects`)

  // Map redirect data to the format Netlify expects
  // https://www.netlify.com/docs/redirects/
  redirects = redirects.map(redirect => {
    const status = redirect.isPermanent ? 301 : 302
    return `${redirect.fromPath}  ${redirect.toPath}  ${status}`
  })

  let appendToFile = false

  // Websites may also have statically defined redirects
  // In that case we should append to them (not overwrite)
  // Make sure we aren't just looking at previous build results though
  const fileExists = await exists(FILE_PATH)
  if (fileExists) {
    const fileContents = await readFile(FILE_PATH)
    if (fileContents.indexOf(HEADER_COMMENT) < 0) {
      appendToFile = true
    }
  }

  const data = `${HEADER_COMMENT}\n\n${redirects.join(`\n`)}`

  return appendToFile
    ? appendFile(FILE_PATH, `\n\n${data}`)
    : writeFile(FILE_PATH, data)
}
Beispiel #4
0
module.exports = async (registry, {cwd, env: {NPM_TOKEN, NPM_USERNAME, NPM_PASSWORD, NPM_EMAIL}, logger}) => {
  logger.log('Verify authentication for registry %s', registry);
  const config = path.resolve(cwd, '.npmrc');
  if (getAuthToken(registry, {npmrc: rc('npm', {registry: 'https://registry.npmjs.org/'}, {config})})) {
    return;
  }
  if (NPM_USERNAME && NPM_PASSWORD && NPM_EMAIL) {
    await appendFile(config, `\n_auth = \${LEGACY_TOKEN}\nemail = \${NPM_EMAIL}`);
    logger.log(`Wrote NPM_USERNAME, NPM_PASSWORD and NPM_EMAIL to ${config}`);
  } else if (NPM_TOKEN) {
    await appendFile(config, `\n${nerfDart(registry)}:_authToken = \${NPM_TOKEN}`);
    logger.log(`Wrote NPM_TOKEN to ${config}`);
  } else {
    throw new AggregateError([getError('ENONPMTOKEN', {registry})]);
  }
};
Beispiel #5
0
	fs.appendFile(file, 'hi1', function(e){
		console.log(e);

		fs.appendFile(file, 'hi2', function(e){
			console.log(e);
		});
	});
Beispiel #6
0
var log = function(message) {
  if (_.isObject(message)) message = JSON.stringify(message, null, 2) + '\n\n';

  fs.appendFile(logFile, message, function(err) {
    if (err) console.error(err);
  });
};
Beispiel #7
0
  writeFile: function(opts, result) {
    var fields = opts.fields ? opts.fields : (typeof opts.output.length == 'undefined' ? Object.keys(opts.output) : Object.keys(opts.output[0]));
    var exists = true;

    var csv = json2csv({
      data: result,
      fields: fields
    });

    try {
      fs.statSync(opts.file);
    } catch(e) {
      exists = false;
    }

    if (exists) {
      csv = csv.substring(csv.indexOf("\n") + 1);
      fs.appendFile(opts.file, "\n" + csv, this.error);
    } else {
      fs.ensureFile(opts.file, function(error) {
        this.error(error);
        fs.writeFile(opts.file, csv, this.error);
      }.bind(this))
    };
  },
 function makeOutputFile(content,fileName){
   var outputFile = __dirname+'/../'+fileName.replace(/wav/,"txt");
   fs.appendFile(outputFile,content, function (err) {
       if (err) return console.log(err);
       console.log("output file created");
   });
 }
Beispiel #9
0
exports.writeLog = function (type, data, dailySplit) {
	if (dailySplit) {
		var stream = exports.getDailyStream(type);
		stream.write(data + '\n');
	} else {
		fs.appendFile(logDir + '/' + type + '.log', data + '\n');
	}
};
Beispiel #10
0
				return parseLinesForMeta(ip, channel, lines, function (err) {
					if (err) return next(err);
					return FS.appendFile(path, "[" + (new Date().toISOString()) + "] " + lines + "\n", function (err) {
						if (err) return next(err);
						res.writeHead(200);
						return res.end("");
					});
				});
Beispiel #11
0
app.use(function (err, req, res, next) {
  console.log('\n' + chalk.red('Exception in routes stack:'))
  console.error(err.stack)
  if (!err.statusCode || err.statusCode === 500) {
    if (process.env.ERR_REPORT) fs.appendFile('./.errorlog', err.stack)
  }
  res.status(err.statusCode || 500).send(err.message)
})
Beispiel #12
0
 fs.ensureFile(filename, function (err) {
     if (err) { node.error(RED._("file.errors.createfail",{error:err.toString()}),msg); }
     else {
         fs.appendFile(filename, data, "binary", function (err) {
             if (err) { node.error(RED._("file.errors.appendfail",{error:err.toString()}),msg); }
         });
     }
 });
Beispiel #13
0
module.exports = async (registry, logger) => {
  logger.log('Verify authentication for registry %s', registry);
  const {NPM_TOKEN, NPM_USERNAME, NPM_PASSWORD, NPM_EMAIL} = process.env;

  if (getAuthToken(registry)) {
    return;
  }
  if (NPM_USERNAME && NPM_PASSWORD && NPM_EMAIL) {
    await appendFile('./.npmrc', `\n_auth = ${Buffer.from(`\${LEGACY_TOKEN}\nemail = \${NPM_EMAIL}`)}`);
    logger.log('Wrote NPM_USERNAME, NPM_PASSWORD and NPM_EMAIL to .npmrc.');
  } else if (NPM_TOKEN) {
    await appendFile('./.npmrc', `\n${nerfDart(registry)}:_authToken = \${NPM_TOKEN}`);
    logger.log('Wrote NPM_TOKEN to .npmrc.');
  } else {
    throw new AggregateError([getError('ENONPMTOKEN', {registry})]);
  }
};
Beispiel #14
0
	// append css
	function appendCSS() {
		fs.appendFile(path, css, function (err) {
			if (err) {
				console.log('\n'+err+'\n')
			} else {
				send(200);
			}
		});
	}
	Controller.filelog = function() {
		var args = Array.prototype.slice.call(arguments, 0);
		var line = args.join(' ') + '\n';
		fs.appendFile(LOG_FILE, line, function(err) {
			if(err) {
				console.warn(err);
			}
		});
	};
Beispiel #16
0
 var writeFile = function(err){
   if(!found){
     fs.appendFile(path, content, function () {
       then(err, found);
     });
   }else{
     then(err, found);
   }
 };
Beispiel #17
0
 helper.load(tailNode, flow, function() {
     var tailNode1 = helper.getNode("tailNode1");
     var helperNode1 = helper.getNode("helperNode1");
     helperNode1.on("input", function(msg) {
         //console.log(msg);
         msg.should.have.property('topic', fileToTail);
         msg.payload.should.equal("Tail message line 5\nTail message line 6\n");
         done();
     });
     fs.appendFile(fileToTail, "Tail message line 5\nTail message line 6\n");
 });
Beispiel #18
0
  it('remote', async () => {
    await helpers.remote.ignorePreviousChanges()
    const localPath = path.join(helpers.local.syncPath, 'file')

    const file = await cozy.files.create('basecontent', { name: 'file' })
    await helpers.remote.pullChanges()
    await helpers.syncAll()

    // update only the file mtime
    await cozy.files.updateById(file._id, 'changedcontent', {
      contentType: 'text/plain'
    })
    await cozy.files.updateById(file._id, 'basecontent', {
      contentType: 'text/plain'
    })

    const statBefore = await fse.stat(localPath)
    helpers.spyPouch()
    await helpers.remote.pullChanges()
    await helpers.syncAll()

    const statAfter = await fse.stat(localPath)
    statBefore.mtime.toISOString().should.equal(statAfter.mtime.toISOString())

    // actually change the file
    await fse.appendFile(localPath, ' appended')

    if (config.watcherType() === 'chokidar') {
      const stats = await fse.stat(localPath)
      await helpers.local.simulateEvents([
        {
          type: 'change',
          path: 'file',
          stats
        }
      ])
    } else {
      await helpers.local.simulateAtomStart()
      await helpers.local.simulateAtomEvents([
        [
          {
            action: 'modified',
            kind: 'file',
            path: 'file'
          }
        ]
      ])
    }

    await helpers.syncAll()

    should(await fse.readFile(localPath, 'utf8')).equal('basecontent appended')
    should((await fse.stat(localPath)).mtime).not.equal(statAfter.mtime)
  })
var errorlog_outputlog = function(options){
	var logdata = options.logdata+'\r\n ';
	logger.error(logdata);
	fs.appendFile(logfile,logdata+'====!!ERROR!!====',function(err){
		if(err){
			logger.error(err);
		}
		if(options.cli){
			process.exit(0);
		}
	});
};
Beispiel #20
0
var install_logErrorOutput = function (options) {
	var logfile = options.logfile,
		logdata = options.logdata + '\r\n ';
	logger.error(logdata);
	fs.appendFile(logfile, logdata + '====!!ERROR!!====', function (err) {
		if (err) {
			logger.error(err);
		}
		if (options.cli) {
			throw new Error(logdata);
		}
	});
};
Beispiel #21
0
        fs.outputFile(upmpdcliconf, namestring , function (err) {

            if (err) {
                self.logger.error('Cannot write upnp conf file: '+err);
            } else {
                fs.appendFile(upmpdcliconf, fs.readFileSync(upmpdcliconftmpl), function (err) {
                    if (err){
                        self.logger.error('Cannot write upnp conf file: '+err);
                    }
                    upmpdcliexec();
                });
            }
        })
Beispiel #22
0
test('Filter modified files, including files in .gitignore and untracked ones', async t => {
  // Create a git repository, set the current working directory at the root of the repo
  const {cwd} = await gitRepo();
  // Create files
  await outputFile(path.resolve(cwd, 'file1.js'), '');
  await outputFile(path.resolve(cwd, 'dir/file2.js'), '');
  await outputFile(path.resolve(cwd, 'file3.js'), '');
  // Create .gitignore to ignore file3.js
  await outputFile(path.resolve(cwd, '.gitignore'), 'file.3.js');
  // Add files and commit
  await add(['.'], {cwd});
  await commit('Test commit', {cwd});
  // Update file1.js, dir/file2.js and file3.js
  await appendFile(path.resolve(cwd, 'file1.js'), 'Test content');
  await appendFile(path.resolve(cwd, 'dir/file2.js'), 'Test content');
  await appendFile(path.resolve(cwd, 'file3.js'), 'Test content');
  // Add untracked file
  await outputFile(path.resolve(cwd, 'file4.js'), 'Test content');

  await t.deepEqual(
    (await filterModifiedFiles(['file1.js', 'dir/file2.js', 'file3.js', 'file4.js'], {cwd})).sort(),
    ['file1.js', 'dir/file2.js', 'file3.js', 'file4.js'].sort()
  );
});
Beispiel #23
0
   /**
    * Log a completed animation
    * @param  {Function} next Function to call when done
    */
   function logComplete(next) {
      if (logDir) {
         fs.mkdirs(logDir);
         var datetime = new Date().toISOString().substring(0, 19);
         var date = new Date().toISOString().substring(0, 10);

         var line = [datetime, hash, 'animation', status.state, slices.length];
         line = line.join(',') + '\n';
         fs.appendFile(path.join(logDir, date + '.csv'), line, function(err) {
            if (next) {
               next(err);
            }
         });
      }
   }
Beispiel #24
0
    return new Promise(function(resolve, reject) {
      console.log('Will store data', mpath);
      var textd = textifyObj(d);
      if( e === "create") {
        fs.appendFile( mpath, textd, function(err) {
          if (err) reject( err);
          resolve(parseData(textd));
        });
      }
		  if( e === "update") {
        fs.writeFile( mpath, textd, function(err) {
        if (err) reject( err);
          resolve(parseData(textd));
        });
      }
    });
var update_outputlog = function(options){
	var logdata = options.logdata+'\r\n',
			callback = options.callback;

	fs.appendFile(logfile,logdata,function(err){
		if(err){
			logger.error(err);
			callback(err);
			//try and write message to end console
			errorlog_outputlog({
				logfile : logfile,
				logdata : err.message
			});
		}
		else{
			if(callback){
				callback(null);
			}
		}
	});
};
        var handle = function (err) {

            var errorLogPath = require('path').join(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE, 'Prepros-Error-Log.html');

            fs.appendFile(errorLogPath, ' <div class="error"> \n <b> [ ' + new Date().toDateString() + ' : ' + new Date().toTimeString() + ' ]</b> \n <pre>\n ' + err.stack.toString() + '\n </pre> \n <hr> \n </div> \n');

            console.error(err, err.stack);

            if (err.message.indexOf('watch ') >= 0 || err.code === 'ECONNRESET') {
                return;
            }

            //Show and focus window
            Prepros.Window.show();
            Prepros.Window.focus();

            //Disable actions to prevent further errors
            $('body').css({pointerEvents: 'none'});
            $('.title-bar__control__icon.icon-close').parent('div').css({pointerEvents: 'auto'});
            $('.title-bar-sidebar-overlay').hide();
            $('.wrapper').html('<div style="margin: auto; display: block; text-align: center"><h1 style="font-size: 400%; font-weight: 200">Prepros Crashed :( </h1><p>I know you are feeling bad, I am also feeling the same :( <br> Please contact ' + Prepros.urls.emali + ' with error log file. <br>' + errorLogPath + '</p></div>');
        };
Beispiel #27
0
var install_logOutput = function (options) {
	var logfile = options.logfile,
		logdata = options.logdata + '\r\n',
		callback = options.callback;

	fs.appendFile(logfile, logdata, function (err) {
		if (err) {
			logger.error(err);
			callback(err);
			//try and write message to end console
			install_logErrorOutput({
				logfile: logfile,
				logdata: err.message
			});
		}
		else {
			if (callback) {
				callback(null);
			}
		}
	});
};
    fs.readFile(filePath, function (err, data) {
      if (err) {
        throw err;
      }
      fs.appendFile(tmpPath, data, function (err) {
        if (err) {
          throw err;
        }

        var filesize = fs.statSync(tmpPath).size;

        console.info('filesize: ' + filesize + ', exxpected: ' + fileMD.expectedSize);

        if (fileMD.expectedSize === filesize) {
          var targetPath = tmpPath.replace('.' + id + TMP_POSTFIX, '');
          fs.renameSync(tmpPath, targetPath);
          res.status(200).send('OK');
        } else {
          res.status(206).send('OK');
        }
      });
    });
module.exports = async function writeRedirectsFile(
  redirects,
  redirectsFilePath,
) {
  if (!redirects.length) {
    return null;
  }

  // Map redirect data to the format Netlify expects
  // https://www.netlify.com/docs/redirects/
  redirects = redirects.map(redirect => {
    const {
      fromPath,
      isPermanent,
      redirectInBrowser, // eslint-disable-line no-unused-vars
      toPath,
      ...rest
    } = redirect;

    // The order of these parameters is significant.
    const pieces = [
      fromPath,
      toPath,
      isPermanent ? 301 : 302, // Status
    ];

    for (let key in rest) {
      const value = rest[key];

      if (typeof value === `string` && value.indexOf(` `) >= 0) {
        console.warn(
          `Invalid redirect value "${value}" specified for key "${key}". ` +
            `Values should not contain spaces.`,
        );
      } else {
        pieces.push(`${key}=${value}`);
      }
    }

    return pieces.join(`  `);
  });

  let appendToFile = false;

  // Websites may also have statically defined redirects
  // In that case we should append to them (not overwrite)
  // Make sure we aren't just looking at previous build results though
  const fileExists = await exists(redirectsFilePath);
  if (fileExists) {
    const fileContents = await readFile(redirectsFilePath);
    if (fileContents.indexOf(HEADER_COMMENT) < 0) {
      appendToFile = true;
    }
  }

  const data = `${HEADER_COMMENT}\n\n${redirects.join(`\n`)}`;

  return appendToFile
    ? appendFile(redirectsFilePath, `\n\n${data}`)
    : writeFile(redirectsFilePath, data);
};
Beispiel #30
0
 fse.ensureDir(logDir, function(){
   fse.appendFile(path.join(logDir, isoDate + '.txt'), row);
 });