Ejemplo n.º 1
0
let asyncThrows = Q.async(function* (fn, name, fp1, msgRe) {
  let throwAgain = false, doesMatch = true, msg;

  yield fs.rename(fp1, 'metadata.json');

  try {
    yield fn();
    throwAgain = true;
  } catch (err) {
    if (msgRe) {
      doesMatch = msgRe.test(err.message);
      msg = err.message;
    }
  } finally {
    yield fs.rename('metadata.json', fp1);

    if (throwAgain) {
      throw new Error(`expected ${name} to throw an error`);
    }
    else if (!doesMatch) {
      let errMsg = `error message doesn\'t match the pattern ${msgRe}\nError: ${msg}`;
      throw new Error(errMsg);
    }
  }
});
Ejemplo n.º 2
0
let createNewElement = Q.async(function* (el) {
  let repo = 'polymerelements/seed-element';
  // download and extrac the seed-element
  let repoPath = yield utils.extractGhRepo(repo, '.', el.name);
  el.install = repoPath;

  yield fs.removeTree(path.resolve(repoPath, '.github'));

  let replacePaths = yield globby([`${repoPath}/**`], {nodir: true});

  // replace the text `seed-element` with the name of the new element
  yield Promise.all(replacePaths.map(Q.async(function*(p) {
    let content = yield fs.read(p);
    let ccName = utils.toCamelCase(el.name);

    content = content.replace(/seedElement/g, ccName);
    content = content.replace(/seed-element/g, el.name);

    yield fs.write(p, content);
  })));

  let fromPath = path.resolve(repoPath, 'seed-element.html');
  let toPath = path.resolve(repoPath, `${el.name}.html`);
  // rename the paths to the new name
  yield fs.rename(fromPath, toPath);

  return el;
});
Ejemplo n.º 3
0
                .then(dirExists=> {
                    if (dirExists) {

                        this.logger.warn(`Due to recording split in LIVE_BACKUP, renaming [${unknownEntry}] recording content dir to [${backupRecordedEntryId}], archive path [${targetArchivePath}]`);
                        return qio.rename(unknownRecordedEntryIdPath, targetArchivePath);
                    }
                })
Ejemplo n.º 4
0
 return qio.exists(jsonPath).then((isExist)=>{
     if (isExist && options.useSameJson == false){
         let jsonPathNew = path.join(jsonPath + "_"+ new Date().getTime().toString())
         logger.info("Found playlist json exist, rename it to %s", jsonPathNew)
         return qio.rename(jsonPath, jsonPathNew)
     }
 })
Ejemplo n.º 5
0
 return qio.isDirectory(targetPath).then(function (res) {
     if (res) {
         logger.debug("Removing directory " + targetPath);
         var renamedFolderName = path.join(config.get("oldContentFolderPath"), newName + '_' + (new Date()).getTime().toString());
         return qio.rename(targetPath, renamedFolderName);
     }
 }).then(function () {
Ejemplo n.º 6
0
let asyncDoesNotThrow = Q.async(function* (fn, name, fp1) {
  let throwAgain = false;

  yield fs.rename(fp1, 'metadata.json');

  try {
    yield fn();
  } catch (err) {
    throwAgain = true;
  } finally {
    yield fs.rename('metadata.json', fp1);

    if (throwAgain) {
      throw new Error(`expected ${name} to not throw an error`);
    }
  }
});
Ejemplo n.º 7
0
function renameOldLog ( o ) {
    var newLogPath = path.join(
            logDir,
            logInfoToName(o)
        );

    return QFS.rename(oldLogPath, newLogPath)
}
Ejemplo n.º 8
0
 .then(({fullPath}) => {
     let renamedFolderName = path.join(fullPath, newName + '_' + (new Date()).getTime().toString());
     return qio.rename(targetPath, renamedFolderName);
 });
Ejemplo n.º 9
0
 .then( () => {
     return FS.rename(path.join(tempIpaPath, 'zipped.ipa'), ipaPath);
 });
Ejemplo n.º 10
0
 .then( () => {
     // Backup the original .ipa
     var origIpaPath = path.join(path.dirname(ipaPath), path.basename(ipaPath,'.ipa') + "-orig.ipa");
     return FS.rename(ipaPath, origIpaPath);
 })
 var remove = function remove(){
     return qio.rename(manifestFullPath, manifestFullPath + '.removed');
 }
Ejemplo n.º 12
0
 }).then(function() {
     return FS.rename(tmpFilePath, filePath);
 });