-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from mattiasw/custom-build-v2
Custom build v2
- Loading branch information
Showing
20 changed files
with
913 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
node_modules/**/* | ||
dist | ||
webpack.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"rules": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const path = require('path'); | ||
const {execSync} = require('child_process'); | ||
const dependentHasExifReaderConfig = require('./findDependentConfig'); | ||
|
||
process.chdir(path.join(__dirname, '..')); | ||
|
||
if (!process.argv.includes('--only-with-config') || checkConfig()) { | ||
execSync('webpack', {stdio: 'inherit'}); | ||
} | ||
|
||
function checkConfig() { | ||
if (dependentHasExifReaderConfig()) { | ||
if (!isDependenciesInstalled()) { | ||
console.log('Installing ExifReader custom build dependencies...'); | ||
execSync('npm install --no-optional --no-package-lock'); | ||
console.log('Done.'); | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
function isDependenciesInstalled() { | ||
try { | ||
execSync('npm ls webpack'); | ||
return true; | ||
} catch (error) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const path = require('path'); | ||
|
||
module.exports = getConfigFromParent.bind(null, path.join(__dirname, '..')); | ||
|
||
function getConfigFromParent(directory) { | ||
const parentDirectory = path.join(directory, '..'); | ||
if (parentDirectory === directory) { | ||
return false; | ||
} | ||
|
||
try { | ||
const packageJson = require(path.join(parentDirectory, 'package.json')); | ||
return packageJson.exifreader; | ||
} catch (error) { | ||
return getConfigFromParent(parentDirectory); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
export default { | ||
USE_FILE: true, | ||
USE_EXIF: true, | ||
USE_IPTC: true, | ||
USE_XMP: true, | ||
USE_ICC: true, | ||
USE_THUMBNAIL: true, | ||
USE_TIFF: true, | ||
USE_JPEG: true, | ||
USE_PNG: true, | ||
USE_HEIC: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
/** | ||
* ExifReader | ||
* http://github.com/mattiasw/exifreader | ||
* Copyright (C) 2011-2018 Mattias Wallander <[email protected]> | ||
* Copyright (C) 2011-2020 Mattias Wallander <[email protected]> | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import {objectAssign} from './utils'; | ||
import DataViewWrapper from './dataview'; | ||
import Constants from './constants'; | ||
import ImageHeader from './image-header'; | ||
import Tags from './tags'; | ||
import FileTags from './file-tags'; | ||
|
@@ -45,7 +46,7 @@ export function loadView(dataView, options = {expanded: false}) { | |
|
||
const {fileDataOffset, tiffHeaderOffset, iptcDataOffset, xmpChunks, iccChunks, pngHeaderOffset} = ImageHeader.parseAppMarkers(dataView); | ||
|
||
if (hasFileData(fileDataOffset)) { | ||
if (Constants.USE_JPEG && Constants.USE_FILE && hasFileData(fileDataOffset)) { | ||
foundMetaData = true; | ||
const readTags = FileTags.read(dataView, fileDataOffset); | ||
if (options.expanded) { | ||
|
@@ -54,7 +55,7 @@ export function loadView(dataView, options = {expanded: false}) { | |
tags = objectAssign({}, tags, readTags); | ||
} | ||
} | ||
if (hasExifData(tiffHeaderOffset)) { | ||
if (Constants.USE_EXIF && hasExifData(tiffHeaderOffset)) { | ||
foundMetaData = true; | ||
const {Thumbnail: thumbnailTags, ...readTags} = Tags.read(dataView, tiffHeaderOffset); | ||
if (options.expanded) { | ||
|
@@ -66,7 +67,7 @@ export function loadView(dataView, options = {expanded: false}) { | |
tags.Thumbnail = thumbnailTags; | ||
} | ||
} | ||
if (hasIptcData(iptcDataOffset)) { | ||
if (Constants.USE_JPEG && Constants.USE_IPTC && hasIptcData(iptcDataOffset)) { | ||
foundMetaData = true; | ||
const readTags = IptcTags.read(dataView, iptcDataOffset); | ||
if (options.expanded) { | ||
|
@@ -75,7 +76,7 @@ export function loadView(dataView, options = {expanded: false}) { | |
tags = objectAssign({}, tags, readTags); | ||
} | ||
} | ||
if (hasXmpData(xmpChunks)) { | ||
if (Constants.USE_XMP && hasXmpData(xmpChunks)) { | ||
foundMetaData = true; | ||
const readTags = XmpTags.read(dataView, xmpChunks); | ||
if (options.expanded) { | ||
|
@@ -84,7 +85,7 @@ export function loadView(dataView, options = {expanded: false}) { | |
tags = objectAssign({}, tags, readTags); | ||
} | ||
} | ||
if (hasIccData(iccChunks)) { | ||
if (Constants.USE_JPEG && Constants.USE_ICC && hasIccData(iccChunks)) { | ||
foundMetaData = true; | ||
const readTags = IccTags.read(dataView, iccChunks); | ||
if (options.expanded) { | ||
|
@@ -93,7 +94,7 @@ export function loadView(dataView, options = {expanded: false}) { | |
tags = objectAssign({}, tags, readTags); | ||
} | ||
} | ||
if (hasPngFileData(pngHeaderOffset)) { | ||
if (Constants.USE_PNG && hasPngFileData(pngHeaderOffset)) { | ||
foundMetaData = true; | ||
const readTags = PngFileTags.read(dataView, pngHeaderOffset); | ||
if (options.expanded) { | ||
|
@@ -103,7 +104,10 @@ export function loadView(dataView, options = {expanded: false}) { | |
} | ||
} | ||
|
||
const thumbnail = Thumbnail.get(dataView, tags.Thumbnail, tiffHeaderOffset); | ||
const thumbnail = Constants.USE_JPEG | ||
&& Constants.USE_EXIF | ||
&& Constants.USE_THUMBNAIL | ||
&& Thumbnail.get(dataView, tags.Thumbnail, tiffHeaderOffset); | ||
if (thumbnail) { | ||
tags.Thumbnail = thumbnail; | ||
foundMetaData = true; | ||
|
Oops, something went wrong.