Socket
Socket
Sign inDemoInstall

grunt-run-new-script

Package Overview
Dependencies
3
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.0.4

2

package.json
{
"name": "grunt-run-new-script",
"description": "Find new SQL scripts, run them, copy them to a local folder",
"version": "1.0.3",
"version": "1.0.4",
"homepage": "",

@@ -6,0 +6,0 @@ "author": {

@@ -16,6 +16,6 @@ /*

module.exports = function(grunt) {
module.exports = function (grunt) {
// Please see the Grunt documentation for more information regarding task
// creation: http://gruntjs.com/creating-tasks
// Please see the Grunt documentation for more information regarding task
// creation: http://gruntjs.com/creating-tasks

@@ -26,109 +26,117 @@ grunt.registerMultiTask('run_new_script', 'Find new SQL scripts, run them, copy them to a local folder', function () {

// Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
punctuation: '.',
separator: ', '
});
// Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
punctuation: '.',
separator: ', '
});
// Read out the contents of a directory
var files = fs.readdirSync(options.srcDir);
var completedFiles = [];
// Check for local_executed folder and create one if it doesn't exist
if(!fs.existsSync(options.localDir)){
files.forEach((file) => {
fs.mkdirSync(options.localDir);
if (!fs.statSync(options.srcDir + '/' + file).isDirectory()) {
}
completedFiles.push(file);
}
// Read out the contents of a directory
var files = fs.readdirSync(options.srcDir);
var completedFiles = [];
});
files.forEach((file) => {
var files = fs.readdirSync(options.localDir);
var localFiles = [];
if (!fs.statSync(options.srcDir + '/' + file).isDirectory()) {
files.forEach((file) => {
completedFiles.push(file);
if (!fs.statSync(options.localDir + '/' + file).isDirectory()) {
}
localFiles.push(file);
});
}
var files = fs.readdirSync(options.localDir);
var localFiles = [];
});
files.forEach((file) => {
var validList = completedFiles.filter((item) => {
return localFiles.indexOf(item) < 0;
})
if (!fs.statSync(options.localDir + '/' + file).isDirectory()) {
var myDB = db(options.dbConnection);
localFiles.push(file);
myDB.on('execute', function (data) {
}
grunt.log.writeln(data);
});
});
grunt.log.writeln(myDB);
var executeFile = function(validList,index){
var validList = completedFiles.filter((item) => {
return localFiles.indexOf(item) < 0;
})
if (index < validList.length) {
var file = validList[index];
grunt.log.writeln(options.srcDir + file);
var data = fs.readFileSync(options.srcDir + file, 'utf8');
var myDB = db(options.dbConnection);
//grunt.log.writeln(data);
myDB.on('execute', function (data) {
myDB.execute(data.trim(), [], (err, result) => {
grunt.log.writeln(data);
// Copy to local on success
if (err) {
});
grunt.log.writeln(err);
throw new Error(err);
grunt.log.writeln(myDB);
var executeFile = function (validList, index) {
}
if (index < validList.length) {
var file = validList[index];
grunt.log.writeln(options.srcDir + file);
var data = fs.readFileSync(options.srcDir + file, 'utf8');
fs.createReadStream(options.srcDir + file).pipe(fs.createWriteStream(options.localDir + (file)));
executeFile(validList, index + 1);
//grunt.log.writeln(data);
});
myDB.execute(data.trim(), [], (err, result) => {
}
else {
// Copy to local on success
if (err) {
setTimeout(done, 3000);
grunt.log.writeln(err);
throw new Error(err);
}
fs.createReadStream(options.srcDir + file).pipe(fs.createWriteStream(options.localDir + (file)));
executeFile(validList, index + 1);
});
}
else {
setTimeout(done, 3000);
}
}
}
executeFile(validList, 0);
executeFile(validList, 0);
// Iterate over all specified file groups.
//this.files.forEach(function(f) {
// // Concat specified files.
// var src = f.src.filter(function(filepath) {
// // Warn on and remove invalid source files (if nonull was set).
// if (!grunt.file.exists(filepath)) {
// grunt.log.warn('Source file "' + filepath + '" not found.');
// return false;
// } else {
// return true;
// }
// }).map(function(filepath) {
// // Read file source.
// return grunt.file.read(filepath);
// }).join(grunt.util.normalizelf(options.separator));
// Iterate over all specified file groups.
//this.files.forEach(function(f) {
// // Concat specified files.
// var src = f.src.filter(function(filepath) {
// // Warn on and remove invalid source files (if nonull was set).
// if (!grunt.file.exists(filepath)) {
// grunt.log.warn('Source file "' + filepath + '" not found.');
// return false;
// } else {
// return true;
// }
// }).map(function(filepath) {
// // Read file source.
// return grunt.file.read(filepath);
// }).join(grunt.util.normalizelf(options.separator));
// // Handle options.
// src += options.punctuation;
// // Handle options.
// src += options.punctuation;
// // Write the destination file.
// grunt.file.write(f.dest, src);
// // Write the destination file.
// grunt.file.write(f.dest, src);
// // Print a success message.
// grunt.log.writeln('File "' + f.dest + '" created.');
//});
});
// // Print a success message.
// grunt.log.writeln('File "' + f.dest + '" created.');
//});
});
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc