Open tmxkwkfgka opened 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.
Can you try with v0.5.0?
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.