runet-censorship-bypass/pac-generator/generate-PACs.js

30 lines
691 B
JavaScript
Raw Normal View History

2015-11-28 12:20:45 +03:00
'use strict';
var generator = require('./pac-generator');
var normalizedPath = require('path').join(__dirname, 'src');
var outputDir = './generated-PACs';
var fs = require('fs')
try {
fs.mkdirSync( outputDir );
} catch(e) {
if ( e.code != 'EEXIST' ) throw e;
}
fs.readdirSync( normalizedPath )
.filter( file => file.startsWith('blocked-') )
.forEach( file =>
require('./src/'+ file)(
generator.hosts,
generator.ips,
generator,
function generatePac() {
var args = [].slice.call( arguments );
args.unshift( outputDir +'/'+ file )
generator.writeOutputToFile.apply( generator, args );
}
)
);