runet-censorship-bypass/pac-generator/generate-PACs.js
2016-05-08 21:14:08 +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 );
}
)
);