Skip to content

error when using settings.args as a variable #2

@fehmer

Description

@fehmer

I found a problem with your code. When calling Exif multiple times with settings.args as a variable the filename is pushed to the args instead of being replaced.

Test:

const Exif = require('simple-exiftool');

function print(metadata) { console.log('result', metadata.SourceFile); }
function err(error) { console.log('error', error); }

const args = ['-json'];

function read(file) {
    return new Promise(function(resolve, reject) {
        console.log('file: %s, args:', file, args);
        Exif(file, {
            binary: "exiftool",
            args: args
        }, (error, metadata) => {

            if (error) reject(error);
            if (metadata.length) reject(new Error('to many results: '+ metadata.length));
            resolve(metadata);
        });
    })
}

read('one.mp3').then(print, err);
read('two.mp3').then(print, err);
read('three.mp3').then(print, err);

Output:

file: one.mp3, args: [ '-json' ]
file: two.mp3, args: [ '-json', 'one.mp3' ]
file: three.mp3, args: [ '-json', 'one.mp3', 'two.mp3' ]
result one.mp3
error [Error: to many results: 3]
error [Error: to many results: 2]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions