Comparing version 2.1.0 to 3.0.0
@@ -1,2 +0,2 @@ | ||
# [2.1.0](https://github.com/electron/asar/compare/v2.0.3...v2.1.0) (2020-02-19) | ||
# [3.0.0](https://github.com/electron/asar/compare/v2.1.0...v3.0.0) (2020-03-10) | ||
@@ -6,4 +6,9 @@ | ||
* add TypeScript definition ([#190](https://github.com/electron/asar/issues/190)) ([f9eb91d](https://github.com/electron/asar/commit/f9eb91d)) | ||
* require Node 10.12.0 ([#191](https://github.com/electron/asar/issues/191)) ([f1a29ba](https://github.com/electron/asar/commit/f1a29ba1e8465a260b1d6c037957ef14af0b262f)) | ||
### BREAKING CHANGES | ||
* Drops support for Node < 10.12.0 | ||
# Changes By Version | ||
@@ -10,0 +15,0 @@ |
@@ -195,3 +195,3 @@ 'use strict' | ||
fs.unlinkSync(destFilename) | ||
} catch (error) {} | ||
} catch {} | ||
const linkTo = path.join(relativePath, path.basename(file.link)) | ||
@@ -198,0 +198,0 @@ fs.symlinkSync(linkTo, destFilename) |
'use strict' | ||
const fs = require('./wrapped-fs') | ||
const os = require('os') | ||
const path = require('path') | ||
const tmp = require('tmp-promise') | ||
const UINT64 = require('cuint').UINT64 | ||
const { promisify } = require('util') | ||
const stream = require('stream') | ||
const UINT32_MAX = 4294967295 | ||
const UINT32_MAX = 2 ** 32 - 1 | ||
const pipeline = promisify(stream.pipeline) | ||
class Filesystem { | ||
@@ -14,3 +17,3 @@ constructor (src) { | ||
this.header = { files: {} } | ||
this.offset = UINT64(0) | ||
this.offset = BigInt(0) | ||
} | ||
@@ -61,44 +64,32 @@ | ||
const handler = (resolve, reject) => { | ||
const size = file.transformed ? file.transformed.stat.size : file.stat.size | ||
let size | ||
// JavaScript can not precisely present integers >= UINT32_MAX. | ||
if (size > UINT32_MAX) { | ||
const error = new Error(`${p}: file size can not be larger than 4.2GB`) | ||
if (reject) { | ||
return reject(error) | ||
} else { | ||
throw error | ||
} | ||
} | ||
const transformed = options.transform && options.transform(p) | ||
if (transformed) { | ||
const tmpdir = await fs.mkdtemp(path.join(os.tmpdir(), 'asar-')) | ||
const tmpfile = path.join(tmpdir, path.basename(p)) | ||
const out = fs.createWriteStream(tmpfile) | ||
const readStream = fs.createReadStream(p) | ||
node.size = size | ||
node.offset = this.offset.toString() | ||
if (process.platform !== 'win32' && (file.stat.mode & 0o100)) { | ||
node.executable = true | ||
await pipeline(readStream, transformed, out) | ||
file.transformed = { | ||
path: tmpfile, | ||
stat: await fs.lstat(tmpfile) | ||
} | ||
this.offset.add(UINT64(size)) | ||
size = file.transformed.stat.size | ||
} else { | ||
size = file.stat.size | ||
} | ||
return resolve ? resolve() : Promise.resolve() | ||
// JavaScript cannot precisely present integers >= UINT32_MAX. | ||
if (size > UINT32_MAX) { | ||
throw new Error(`${p}: file size can not be larger than 4.2GB`) | ||
} | ||
const transformed = options.transform && options.transform(p) | ||
if (transformed) { | ||
const tmpfile = await tmp.file() | ||
return new Promise((resolve, reject) => { | ||
const out = fs.createWriteStream(tmpfile.path) | ||
const stream = fs.createReadStream(p) | ||
stream.pipe(transformed).pipe(out) | ||
return out.on('close', async () => { | ||
file.transformed = { | ||
path: tmpfile.path, | ||
stat: await fs.lstat(tmpfile.path) | ||
} | ||
return handler(resolve, reject) | ||
}) | ||
}) | ||
} else { | ||
return handler() | ||
node.size = size | ||
node.offset = this.offset.toString() | ||
if (process.platform !== 'win32' && (file.stat.mode & 0o100)) { | ||
node.executable = true | ||
} | ||
this.offset += BigInt(size) | ||
} | ||
@@ -105,0 +96,0 @@ |
'use strict' | ||
const { promisify } = require('util') | ||
const fs = process.versions.electron ? require('original-fs') : require('fs') | ||
const mkdirp = require('mkdirp') | ||
const promisifiedMethods = [ | ||
'lstat', | ||
'mkdtemp', | ||
'readFile', | ||
@@ -19,3 +17,3 @@ 'stat', | ||
if (promisifiedMethods.includes(method)) { | ||
promisified[method] = promisify(fs[method]) | ||
promisified[method] = fs.promises[method] | ||
} else { | ||
@@ -26,5 +24,5 @@ promisified[method] = fs[method] | ||
// To make it more like fs-extra | ||
promisified.mkdirp = promisify(mkdirp) | ||
promisified.mkdirpSync = mkdirp.sync | ||
promisified.mkdirp = (dir) => fs.promises.mkdir(dir, { recursive: true }) | ||
promisified.mkdirpSync = (dir) => fs.mkdirSync(dir, { recursive: true }) | ||
module.exports = promisified |
{ | ||
"name": "asar", | ||
"description": "Creating Electron app packages", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"main": "./lib/asar.js", | ||
@@ -11,3 +11,3 @@ "types": "./lib/index.d.ts", | ||
"engines": { | ||
"node": ">=8.0" | ||
"node": ">=10.12.0" | ||
}, | ||
@@ -33,3 +33,6 @@ "license": "MIT", | ||
"mocha": true | ||
} | ||
}, | ||
"globals": [ | ||
"BigInt" | ||
] | ||
}, | ||
@@ -41,8 +44,5 @@ "tsd": { | ||
"chromium-pickle-js": "^0.2.0", | ||
"commander": "^2.20.0", | ||
"cuint": "^0.2.2", | ||
"glob": "^7.1.3", | ||
"minimatch": "^3.0.4", | ||
"mkdirp": "^0.5.1", | ||
"tmp-promise": "^1.0.5" | ||
"commander": "^4.1.1", | ||
"glob": "^7.1.6", | ||
"minimatch": "^3.0.4" | ||
}, | ||
@@ -54,10 +54,10 @@ "optionalDependencies": { | ||
"@continuous-auth/semantic-release-npm": "^2.0.0", | ||
"@semantic-release/changelog": "^3.0.2", | ||
"@semantic-release/changelog": "^5.0.0", | ||
"electron": "^5.0.0", | ||
"electron-mocha": "^8.0.1", | ||
"lodash": "^4.17.11", | ||
"mocha": "^6.1.4", | ||
"rimraf": "^2.6.3", | ||
"semantic-release": "^15.13.3", | ||
"standard": "^12.0.1", | ||
"electron-mocha": "^8.2.1", | ||
"lodash": "^4.17.15", | ||
"mocha": "^7.0.1", | ||
"rimraf": "^3.0.2", | ||
"semantic-release": "^17.0.4", | ||
"standard": "^14.3.1", | ||
"tsd": "^0.11.0", | ||
@@ -64,0 +64,0 @@ "xvfb-maybe": "^0.2.1" |
# asar - Electron Archive | ||
[![CircleCI build status](https://circleci.com/gh/electron/asar/tree/master.svg?style=svg)](https://circleci.com/gh/electron/asar/tree/master) | ||
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/mrfwfr0uxlbwkuq3?svg=true)](https://ci.appveyor.com/project/electron-bot/asar) | ||
[![dependencies](http://img.shields.io/david/electron/asar.svg?style=flat-square)](https://david-dm.org/electron/asar) | ||
@@ -6,0 +5,0 @@ [![npm version](http://img.shields.io/npm/v/asar.svg?style=flat-square)](https://npmjs.org/package/asar) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5
32634
590
191
+ Addedcommander@4.1.1(transitive)
- Removedcuint@^0.2.2
- Removedmkdirp@^0.5.1
- Removedtmp-promise@^1.0.5
- Removedbluebird@3.7.2(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcuint@0.2.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedrimraf@2.7.1(transitive)
- Removedtmp@0.1.0(transitive)
- Removedtmp-promise@1.1.0(transitive)
Updatedcommander@^4.1.1
Updatedglob@^7.1.6