How to use the fs-jetpack.rename function in fs-jetpack

To help you get started, we’ve selected a few fs-jetpack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NREL / OpenStudio-PAT / app / app / project / setProjectService.js View on Github external
const oldZip = projectDir.path(oldProjectName + '.zip');
            const oldJson = projectDir.path(oldProjectName + '.json');
            const newZip = vm.Project.projectName + '.zip';
            const newJson = vm.Project.projectName + '.json';
            // Note "rename" provides no return
            if (vm.Message.showDebug()) vm.$log.debug('preparing to jet rename');
            if (vm.Message.showDebug()) vm.$log.debug('oldZip', oldZip);
            if (vm.Message.showDebug()) vm.$log.debug('oldJson', oldJson);
            if (vm.Message.showDebug()) vm.$log.debug('newZip', newZip);
            if (vm.Message.showDebug()) vm.$log.debug('newJson', newJson);

            // The project may not have been run; it may not have these files.
            // If these files are missing, jetpack.rename will fail ungracefully
            if (jetpack.exists(oldZip) == 'file') {
              if (vm.Message.showDebug()) vm.$log.debug(oldZip + ' is in project, and is being renamed to ' + newZip + '.');
              jetpack.rename(oldZip, newZip);
            }
            else if (jetpack.exists(oldZip) == 'dir') {
              vm.$log.error(oldZip + ' is a directory, and not a file.');
            }
            else if (jetpack.exists(oldZip) == 'other') {
              vm.$log.error(oldZip + ' is an unknown type.');
            }
            else if (jetpack.exists(oldZip) == false) {
              if (vm.Message.showDebug()) vm.$log.debug(oldZip + ' is not in project.');
            }
            else {
              vm.$log.error('jetpack.exists(' + oldZip + ') generated an unhandled return.');
            }

            if (jetpack.exists(oldJson) == 'file') {
              if (vm.Message.showDebug()) vm.$log.debug(oldJson + ' is in project, and is being renamed to ' + newJson + '.');
github hello-efficiency-inc / ridereceipts / src / renderer / services / puppeteer.js View on Github external
})
    }

    // Check if request invoice button is hidden. Then go ahead download it.
    if (invoiceRequest) {
      await page.click(DOWNLOAD_INVOICE_TRIP)
    }

    ipcRenderer.send('progress', progress)
    await page.waitFor(1500)
  }

  for (let i = 0; i < uniqItems.length; ++i) {
    const filePath = jetpack.find(`${documentDir.path()}/${accountEmail}/Uber/${uniqItems[i].year}/${uniqItems[i].month}/${uniqItems[i].invoice_date}/`, { matching: '*invoice*' })
    if (filePath.length > 0) {
      jetpack.rename(filePath[0], `Invoice-${uniqItems[i].invoice_date}.pdf`)
    }
  }

  ipcRenderer.send('form', DOWNLOADED)

  await page.waitFor(1000)

  store.delete('browserEndpoint')
  await browser.close()
}
github trustcrypto / OnlyKey-App / tasks / release_osx.js View on Github external
var prepareOsSpecificThings = function () {
    // Info.plist
    var info = projectDir.read('resources/osx/Info.plist');
    info = utils.replace(info, {
        productName: manifest.productName,
        version: manifest.version
    });
    finalAppDir.write('Contents/Info.plist', info);

    // Icon
    projectDir.copy('resources/osx/icon.icns', finalAppDir.path('Contents/Resources/icon.icns'));

    // Rename executable, so it looks nice in the installer
    jetpack.rename(finalAppDir.path('Contents/MacOS/nwjs'), manifest.productName);

    return Q();
};
github NREL / OpenStudio-PAT / app / app / project / setProjectService.js View on Github external
else if (jetpack.exists(oldZip) == 'dir') {
              vm.$log.error(oldZip + ' is a directory, and not a file.');
            }
            else if (jetpack.exists(oldZip) == 'other') {
              vm.$log.error(oldZip + ' is an unknown type.');
            }
            else if (jetpack.exists(oldZip) == false) {
              if (vm.Message.showDebug()) vm.$log.debug(oldZip + ' is not in project.');
            }
            else {
              vm.$log.error('jetpack.exists(' + oldZip + ') generated an unhandled return.');
            }

            if (jetpack.exists(oldJson) == 'file') {
              if (vm.Message.showDebug()) vm.$log.debug(oldJson + ' is in project, and is being renamed to ' + newJson + '.');
              jetpack.rename(oldJson, newJson);
            }
            else if (jetpack.exists(oldJson) == 'dir') {
              vm.$log.error(oldJson + ' is a directory, and not a file.');
            }
            else if (jetpack.exists(oldJson) == 'other') {
              vm.$log.error(oldJson + ' is an unknown type.');
            }
            else if (jetpack.exists(oldJson) == false) {
              if (vm.Message.showDebug()) vm.$log.debug(oldJson + ' is not in project.');
            }
            else {
              vm.$log.error('jetpack.exists(' + oldJson + ') generated an unhandled return.');
            }

            // set project Variables
            vm.setProjectVariables(projectDir);
github misega / HTML5-Banners / gulpfile.js View on Github external
fs.find('review/banners', { matching: ['fallback.{jpg,gif,png}'] }).forEach(function(image) {
        var ext = image.split('.').pop();
        fs.rename(image, project.name + '_' + utils.getDimensions(image).formatted + '.' + ext);
    });
github hello-efficiency-inc / ridereceipts / src / renderer / services / puppeteer_uberv2.js View on Github external
for (var i = 0; i < spans.length; i++) {
        if (spans[i].textContent === 'Save Invoice') {
          spans[i].click()
          break
        }
      }
    })

    ipcRenderer.send('progress', progress)
    await page.waitFor(3000)
  }

  for (let i = 0; i < tripData.length; ++i) {
    const filePath = jetpack.find(`${documentDir.path()}/${accountEmail}/Uber/${tripData[i].year}/${tripData[i].month}/${tripData[i].invoice_date}/`, { matching: '*invoice*' })
    if (filePath.length > 0) {
      jetpack.rename(filePath[0], `Invoice-${tripData[i].invoice_date}.pdf`)
    }
  }

  ipcRenderer.send('form', DOWNLOADED)

  await page.waitFor(1000)

  store.delete('browserEndpoint')
  await browser.close()
}