runet-censorship-bypass/pac-generator/generate-PACs.js
Ilya Ig. Petrov 00d23d0292 refactored
2015-11-28 14:20:45 +05:00

30 lines
691 B
JavaScript
Executable File

'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 );
}
)
);