mmmagic icon indicating copy to clipboard operation
mmmagic copied to clipboard

magic.detectFile ended without throwing error

Open tmxkwkfgka opened this issue 8 years ago • 1 comments

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.

tmxkwkfgka avatar Nov 01 '17 05:11 tmxkwkfgka

Can you try with v0.5.0?

mscdex avatar Feb 27 '18 20:02 mscdex