exifreader 4.16.0 → 4.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -372,13 +372,21 @@ tags (resulting bundle will be ~19 % of a gzipped full build):
372
372
  ```
373
373
 
374
374
  Then, if you didn't install ExifReader yet, run `npm install exifreader`.
375
- Otherwise you have to re-build the library:
375
+ Otherwise you have to rebuild the library:
376
376
 
377
377
  ```bash
378
378
  npm rebuild exifreader
379
379
  ```
380
380
 
381
- If you use `yarn`, run `yarn add exifreader` to rebuild the library.
381
+ With yarn 2+:
382
+ ```bash
383
+ yarn rebuild exifreader
384
+ ```
385
+
386
+ With yarn 1:
387
+ ```bash
388
+ yarn add exifreader
389
+ ```
382
390
 
383
391
  After that the new bundle is here: `node_modules/exifreader/dist/exif-reader.js`
384
392
 
package/bin/build.js CHANGED
@@ -3,18 +3,22 @@
3
3
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
4
 
5
5
  const path = require('path');
6
+ const fs = require('fs');
6
7
  const {execSync} = require('child_process');
7
8
  const dependentHasExifReaderConfig = require('./findDependentConfig');
8
9
 
9
- process.chdir(path.join(__dirname, '..'));
10
+ const WEBPACK_VERSION = '5.89.0';
11
+
12
+ const EXIFREADER_ROOT_DIR = path.join(__dirname, '..');
13
+ process.chdir(EXIFREADER_ROOT_DIR);
10
14
 
11
15
  if (!process.argv.includes('--only-with-config') || checkConfig()) {
12
- execSync('webpack', {stdio: 'inherit'});
16
+ execSync(`npx webpack@${WEBPACK_VERSION}`, {stdio: 'inherit'});
13
17
  }
14
18
 
15
19
  function checkConfig() {
16
20
  if (dependentHasExifReaderConfig()) {
17
- if (!isDependenciesInstalled()) {
21
+ if (!areDependenciesInstalled()) {
18
22
  console.log('Installing ExifReader custom build dependencies...'); // eslint-disable-line no-console
19
23
  const packages = [
20
24
  '@babel/core@7.23.2',
@@ -23,19 +27,27 @@ function checkConfig() {
23
27
  'babel-loader@8.2.5',
24
28
  'cross-env@7.0.3',
25
29
  'string-replace-loader@3.1.0',
26
- 'webpack@5.89.0',
30
+ `webpack@${WEBPACK_VERSION}`,
27
31
  'webpack-cli@5.1.4',
28
32
  'terser-webpack-plugin@5.3.9'
29
33
  ];
30
- execSync(`npm install --production=false --loglevel=error --no-optional --no-package-lock --no-save ${packages.join(' ')}`, {stdio: 'inherit'});
31
- console.log('Done.'); // eslint-disable-line no-console
34
+ const tmpDir = path.join(EXIFREADER_ROOT_DIR, '__tmp');
35
+ try {
36
+ initTmpDir(tmpDir);
37
+ execSync(`npm install --production --loglevel=error --no-optional --no-package-lock --no-save ${packages.join(' ')}`, {stdio: 'inherit'});
38
+ console.log('Done.'); // eslint-disable-line no-console
39
+ } catch (error) {
40
+ console.error('Could not install requirements for a custom build:', error); // eslint-disable-line no-console
41
+ } finally {
42
+ cleanUpTmpDir(tmpDir);
43
+ }
32
44
  }
33
45
  return true;
34
46
  }
35
47
  return false;
36
48
  }
37
49
 
38
- function isDependenciesInstalled() {
50
+ function areDependenciesInstalled() {
39
51
  try {
40
52
  execSync('npm ls webpack');
41
53
  return true;
@@ -43,3 +55,22 @@ function isDependenciesInstalled() {
43
55
  return false;
44
56
  }
45
57
  }
58
+
59
+ function initTmpDir(tmpDir) {
60
+ const nodeModulesDir = path.join(EXIFREADER_ROOT_DIR, 'node_modules');
61
+ fs.mkdirSync(tmpDir, {recursive: true});
62
+ if (fs.existsSync(nodeModulesDir)) {
63
+ fs.renameSync(nodeModulesDir, path.join(tmpDir, 'node_modules'));
64
+ }
65
+ process.chdir(tmpDir);
66
+ execSync('npm init -y', {stdio: 'inherit'});
67
+ }
68
+
69
+ function cleanUpTmpDir(tmpDir) {
70
+ const nodeModulesDir = path.join(tmpDir, 'node_modules');
71
+ if (fs.existsSync(nodeModulesDir)) {
72
+ fs.renameSync(nodeModulesDir, path.join(EXIFREADER_ROOT_DIR, 'node_modules'));
73
+ }
74
+ process.chdir(EXIFREADER_ROOT_DIR);
75
+ fs.rmSync(tmpDir, {recursive: true, force: true});
76
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exifreader",
3
- "version": "4.16.0",
3
+ "version": "4.17.0",
4
4
  "description": "Library that parses Exif metadata in images.",
5
5
  "author": "Mattias Wallander <mattias@wallander.eu>",
6
6
  "repository": {
Binary file