1 //普通读取方法
2 // var data = fs.readFileSync(versionpath,'utf8');
3 // var dataarr = data.split('\n');
4 // dataarr.forEach(function(dataarr) {
5 // if( dataarr.indexOf('version') > -1) {
6 // version = (dataarr.split(':')[1]).match(/\"(.*)\"/)[1];
7 // return;
8 // }
9 // })
//按行读取
// 创建写入临时文件夹
if(!fs.existsSync('./yotmp')){
fs.mkdirSync('./yotmp');
}
// tmpPath = './yotmp/version.scss';
// fs.writeFileSync(tmpPath, '');
var file = fs.createReadStream(versionpath);
var out = fs.createWriteStream('./yotmp/varialbes.scss');
log(out);
var rl = readline.createInterface({
input: file,
output: out
});
rl.on('line', function (line){
log('line:' + line);
if( line.indexOf('version') > -1) {
version = (line.split(':')[1]).match(/\"(.*)\"/)[1];
fsUtil.rmDirSync('./yotmp');
log("///////////////");
rl.close();
return;
}
});