How to use the asar.createPackageWithOptions function in asar

To help you get started, we’ve selected a few asar 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 electron / electron / script / gn-asar.js View on Github external
// Copy all files to a tmp dir to avoid including scrap files in the ASAR
  for (const file of files) {
    const newLocation = path.resolve(tmpPath, path.relative(base[0], file))
    fs.mkdirsSync(path.dirname(newLocation))
    fs.writeFileSync(newLocation, fs.readFileSync(file))
  }
} catch (err) {
  console.error('Unexpected error while generating ASAR', err)
  fs.remove(tmpPath)
    .then(() => process.exit(1))
    .catch(() => process.exit(1))
  return
}

// Create the ASAR archive
asar.createPackageWithOptions(tmpPath, out[0], {})
  .catch(err => {
    const exit = () => {
      console.error('Unexpected error while generating ASAR', err)
      process.exit(1)
    }
    fs.remove(tmpPath).then(exit).catch(exit)
  }).then(() => fs.remove(tmpPath))
github electron / electron / spec / coverage / instrument.js View on Github external
var libPath = path.join(__dirname, '..', '..', 'lib')

rimraf.sync(path.join(outputPath, 'lib'))

glob.sync('**/*.js', {cwd: libPath}).forEach(function (relativePath) {
  var rawPath = path.join(libPath, relativePath)
  var raw = fs.readFileSync(rawPath, 'utf8')

  var generatedPath = path.join(outputPath, 'lib', relativePath)
  var generated = instrumenter.instrumentSync(raw, rawPath)
  mkdirp.sync(path.dirname(generatedPath))
  fs.writeFileSync(generatedPath, generated)
})

var asarPath = path.join(outputPath, 'electron.asar')
asar.createPackageWithOptions(path.join(outputPath, 'lib'), asarPath, {}, function (error) {
  if (error) {
    console.error(error.stack || error)
    process.exit(1)
  }
})
github electron / electron-packager / platform.js View on Github external
asarApp () {
    if (!this.asarOptions) {
      return Promise.resolve()
    }

    debug(`Running asar with the options ${JSON.stringify(this.asarOptions)}`)
    return asar.createPackageWithOptions(this.originalResourcesAppDir, this.appAsarPath, this.asarOptions)
      .then(() => fs.remove(this.originalResourcesAppDir))
  }
github beakerbrowser / beaker / tasks / release / linux.js View on Github external
var packageBuiltApp = function () {
  var deferred = Q.defer();

  asar.createPackageWithOptions(projectDir.path('app'), readyAppDir.path('resources/app.asar'), {
    dot: true
  }, function () {
    deferred.resolve();
  });

  return deferred.promise;
};
github paulsutherland / Polyonic / tasks / release / windows.js View on Github external
let packageBuiltApp = function () {
  let deferred = Q.defer()

  asar.createPackageWithOptions(projectDir.path('build'), readyAppDir.path('resources/app.asar'), {
    dot: true
  }, function () {
    deferred.resolve()
  })

  return deferred.promise
}
github paulsutherland / Polyonic / tasks / release / linux.js View on Github external
let packageBuiltApp = function () {
  let deferred = Q.defer()

  asar.createPackageWithOptions(projectDir.path('build'), readyAppDir.path('resources/app.asar'), {
    dot: true
  }, function () {
    deferred.resolve()
  })

  return deferred.promise
}
github beakerbrowser / beaker / tasks / release / windows.js View on Github external
var packageBuiltApp = function () {
  var deferred = Q.defer();

  asar.createPackageWithOptions(projectDir.path('app'), readyAppDir.path('resources/app.asar'), {
    dot: true
  }, function () {
    deferred.resolve();
  });

  return deferred.promise;
};
github twofactor / MenubarNotes / node_modules / electron-packager / common.js View on Github external
function asarApp (appPath, asarOptions, cb) {
  var dest = path.join(appPath, '..', 'app.asar')
  debug(`Running asar with the options ${JSON.stringify(asarOptions)}`)
  asar.createPackageWithOptions(appPath, dest, asarOptions, function (err) {
    if (err) return cb(err)
    fs.remove(appPath, function (err) {
      if (err) return cb(err)
      cb(null, dest)
    })
  })
}
github toyobayashi / mishiro / app / script / pack.ts View on Github external
async function asarApp (root: string) {
  await createPackageWithOptions(root, path.join(root, '../app.asar'), { unpack: process.platform === 'linux' ? `{*.node,**/${path.basename(config.outputPath)}/${config.iconOutDir}/*.png}` : '*.node' })
  await fs.remove(root)
}

asar

Creating Electron app packages

MIT
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis