mscdex / mmmagic

An async libmagic binding for node.js for detecting content types by data inspection
MIT License
618 stars 49 forks source link

magic.detectFile ended without throwing error #118

Open tmxkwkfgka opened 6 years ago

tmxkwkfgka commented 6 years ago
const fs = require('fs');
const async = require('async')
const path = require('path')
const Magic = require('mmmagic').Magic;
const magic = new Magic();

//folderpath = C:\Program Files\MySQL\MySQL Workbench 6.3 CE\modules\data\sqlide
``
function magicAll(folderPath){
    fs.readdir(folderPath, (err, files)=>{
        files.forEach(file=>{
            console.log(file)
            try{
                magic.detectFile(path.join(folderPath, file), (err, res)=>{
                if(err)
                    console.log('detect err = ', err)

                console.log('result = ', res)

            })
            }catch(err){
                console.log('catch err = ', err)
            }

        })
    })
}

magicAll('C:/Program Files/MySQL/MySQL Workbench 6.3 CE/modules/data/sqlide')

console result : CSV.pre.tpl CSV.tpl CSV.tpli CSV_semicolon.pre.tpl CSV_semicolon.tpl CSV_semicolon.tpli HTML.post.tpl HTML.pre.tpl HTML.tpl HTML.tpli JSON.post.tpl JSON.pre.tpl JSON.tpl JSON.tpli SQL_inserts.pre.tpl SQL_inserts.tpl SQL_inserts.tpli tab.pre.tpl tab.tpl tab.tpli XLS.post.tpl XLS.pre.tpl XLS.tpl XLS.tpli XML.post.tpl XML.pre.tpl XML.tpl XML.tpli XML_mysql.post.tpl XML_mysql.pre.tpl XML_mysql.tpl XML_mysql.tpli

my OS : window7

I use magic.detectFile to know type of the file. but when I detect folder: C:\Program Files\MySQL\MySQL Workbench 6.3 CE\modules\data\sqlide which have .tpl .tpli file. detectFile ended without throwing error or result.

mscdex commented 6 years ago

Can you try with v0.5.0?