Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var inputFile = new File({
base: inputBase,
cwd: __dirname,
path: inputPath,
contents: inputContents
});
var onEnd = function(){
buffered.length.should.equal(1);
bufEqual(fs.readFileSync(expectedPath), new Buffer(existingContents)).should.equal(true);
done();
};
// Write expected file which should not be overwritten
fs.mkdirSync(expectedBase);
fs.writeFileSync(expectedPath, existingContents);
var stream = app.dest('./out-fixtures/', {cwd: __dirname, overwrite: false});
var buffered = [];
bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd);
stream.pipe(bufferStream);
stream.write(inputFile);
stream.end();
});
var inputBase = path.join(__dirname, './fixtures/');
var expectedContents = fs.readFileSync(inputPath);
var expectedBase = path.join(__dirname, './actual');
var expectedMode = parseInt('722', 8);
var expectedFile = new File({
base: inputBase,
cwd: __dirname,
path: inputPath,
contents: expectedContents,
stat: {
mode: expectedMode
}
});
fs.mkdirSync(expectedBase);
fs.chmodSync(expectedBase, 0);
var stream = app.symlink('./actual/', {cwd: __dirname});
stream.on('error', function(err) {
err.code.should.equal('EACCES');
cb();
});
stream.write(expectedFile);
});
var expectedPath = path.join(__dirname, 'actual/test.coffee');
var expectedContents = fs.readFileSync(inputPath);
var expectedBase = path.join(__dirname, 'actual');
var expectedMode = 0722;
var expectedFile = new File({
base: inputBase,
cwd: __dirname,
path: inputPath,
contents: expectedContents,
stat: {
mode: expectedMode
}
});
fs.mkdirSync(expectedBase);
fs.closeSync(fs.openSync(expectedPath, 'w'));
fs.chmodSync(expectedPath, 0);
var stream = app.dest('./actual/', {cwd: __dirname});
stream.on('error', function(err) {
err.code.should.equal('EACCES');
done();
});
stream.write(expectedFile);
});
}
if (argv.channel) data = data.filter(function(tag) { return tag && tag.channel == argv.channel });
data.sort(Version.sorterDesc);
for(var i = 0; i < data.length; ++i) {
if(data[i])
console.log(data[i].toString());
}
process.exit();
});
}
var stashDir = path.join(common.paths.root(), '.stashes');
if (!fs.existsSync(stashDir)) {
fs.mkdirSync(stashDir);
}
exports.update = function (tag, next) {
var channel = argv.channel;
tag = tag || argv.tag;
var defaultChildArgs = {
cwd: common.paths.root(),
silent: true
};
var loudChildArgs = {
cwd: common.paths.root(),
silent: false
};
function generatestatic() {
console.log("Generating unique pages...");
const scams = JSON.parse(fs.readFileSync('./_site/data/scams.json'));
const addresses = JSON.parse(fs.readFileSync('./_site/data/addresses.json'));
const ips = JSON.parse(fs.readFileSync('./_site/data/ips.json'));
const layout_scams = fs.readFileSync('./_layouts/scam.html', 'utf8');
const layout_addresses = fs.readFileSync('./_layouts/address.html', 'utf8');
const layout_ips = fs.readFileSync('./_layouts/ip.html', 'utf8');
if (!fs.existsSync("./_site")) {
fs.mkdirSync("./_site/");
}
if (!fs.existsSync("./_site/scam/")) {
fs.mkdirSync("./_site/scam/");
}
for (var key = 0, len = scams.length; key < len; key++) {
var layout = template.replace("{{ content }}", layout_scams);
var sc_nameservers = "";
var sc_addresses = "";
var history = "";
var actions = "<button class="ui icon secondary button" id="share"><i class="share alternate icon"></i> Share</button>";
if ("nameservers" in scams[key]) {
scams[key]['nameservers'].forEach(function(nameindex) {
sc_nameservers += "<div class="item">" + nameindex + '</div>';
});
if (sc_nameservers) {
layout = layout.replace(/{{ scam.nameservers }}/ig, '<b>Nameservers</b>: <div class="ui bulleted list">' + sc_nameservers + '</div>');
layout = layout.replace(/{{ address.address }}/ig, key);
layout = layout.replace(/{{ address.scams }}/ig, related);
if (!fs.existsSync("./_site/address/" + key + "/")) {
fs.mkdirSync("./_site/address/" + key + "/");
}
if (minify) {
layout = htmlmin(layout);
}
fs.writeFile("./_site/address/" + key + "/index.html", layout, function(err) {
if (err) {
return console.log(err);
}
});
});
if (!fs.existsSync("./_site/ip/")) {
fs.mkdirSync("./_site/ip/");
}
Object.keys(ips).forEach(function(key) {
var layout = template.replace("{{ content }}", layout_ips);
var related = "";
for (var i = 0, len = ips[key].length; i < len; i++) {
related += "<div class="item"><a href="/scam/" + ips[key][i] + "">" + data.find(o => o['id'] === ips[key][i])['name'] + "</a></div>"
}
if (related) {
related = '<div class="ui bulleted list">' + related + '</div>'
} else {
related = "None"
}
layout = layout.replace(/{{ ip.ip }}/ig, key);
layout = layout.replace(/{{ ip.scams }}/ig, related);
if (!fs.existsSync("./_site/ip/" + key + "/")) {
fs.mkdirSync("./_site/ip/" + key + "/");
saveToFile : function (c, options) {
var outName = options.filePath.replace(/^.*[\\\/]/, '').replace('.csv', '');
var file = options.outputPath || 'output/' + outName + '.json';
var dirname = file.match(/(.*)[\/\\]/)[1]||'';
if (!fs.existsSync(dirname)){
fs.mkdirSync(dirname);
}
jsonfile.writeFile(file, c.data, { spaces: options.tabSize }, function (err) {
if (!_.isNull(err)) {
throw new gutil.PluginError('gulp-csv-to-json', 'ERROR: Error during save. ' + err);
}
})
},
function makeDirectories(dirpath: string) {
if (fs.existsSync(dirpath)) {
return true;
}
const parent = path.dirname(dirpath);
if ((parent !== dirpath) && makeDirectories(parent)) {
fs.mkdirSync(dirpath);
return true;
} else {
return false;
}
}
function showTextFile(outputFilename: string) {
exports.ensureDir = function ensureDir(dir, clean) {
try {
var paths = fs.readdirSync(dir);
if(clean) {
paths.forEach(function(filename) {
try {
fs.unlinkSync(path.join(dir, filename));
}
catch(e) {
}
});
}
}
catch(e) {
fs.mkdirSync(dir, ACCESS);
}
};
function mkdirs(path) {
if (fs.existsSync(path)) return;
let parent = pathFn.dirname(path);
if (!fs.existsSync(parent)) {
mkdirs(parent);
}
fs.mkdirSync(path);
}