I have a task in Gruntfile.js which can potentially wipe my project and I want to protect it with a "Are you sure you want to run this task?" question before running it, just to be safe. Something like:
grunt.registerTask('install', 'Run this only once when starting a project!', function() {
console.log('Are you sure? Y/n:');
// If yes, continue with task
grunt.task.run('copy_install');
});
But I don't know how to make it wait for keyboard input and read the input. Could not find this documented either.
Don't do it! You will regret this!
Grunt is a build tool and you grunt script should only be able to wipe what it created. No matter what the reasoning behind your current state is, change it. Use the tool for what is was meant to do, not for wiping stuff you dont want to lose.
Take a look at grunt-prompt or grunt-confirm.
Related
I'm not the best at explaining this stuff but here I go.
I have a program that uses "tesseract.js" to read an image every second or so.
10% of images have an "Empty page!!" error message, but I don't need or want this error message flooding my otherwise useful error log. I want to remove it from the source code, however, it isn't fired from the easily readable js code...
I assume it is fired from the wasmBinaryFile section, which (if I understand correctly) is a wasm binary compiled version of the original C++ (Tesseract 4.1.1)
In C++ Tesseract, the error message is fired from \src\textord\colfind.cpp line 366. If I knew where the equivalent section of the binary code was, I assume that I could remove it.
I know that decompiling wasm to C++ won't necessarily be understandable, but if I did it, would I be able to compare it to the source code for Tesseract and either find the section I need to remove or be able to recompile it for use again?
If so, would someone be able to point me towards a good software to do this?
You don't need to revers engineer that code, tesseract is open source, has a github page and you can look at the source code here :
https://github.com/tesseract-ocr/tesseract/blob/main/src/textord/colfind.cpp.
It also means you can use git to get a local copy, modify and compile it. Probably you can even find a way to change tprintf
Sorry to ask this.. but I'm new at using GULP...
I'm using a template built with AngularJS and when I run the command gulp, the console show me the message "**Done Waching code and reloading on changes" but anything happen after several minutes...
It doesn't show any error, it just clean and then compile a lot of things and after that show me that message and nothing else happens.
I was googling this message but it doesnt say anything... Is there a reason for this or a log where I can look for the specific error?
Actually, I'm not sure what I'm expecting to happend.. the browser should be open whit the page?
When you're running gulp.watch(), it starts up a process that is watching your files. It has to keep the process running otherwise it wouldn't be able to recompile your code. This is fine though, this is the intended behavior of watch.
I would like to is flag some piece of code to come back to later. The code is seriously violating our design and I want to ensure that I see it every time I run JSHint until I fix it.
Just as an example suppose that to get something else working I change this code:
addTwoNumbers: function(numberOne, numberTwo){
return numberOne+numberTwo;
}
To this:
addTwoNumbers: function(numberOne, numberTwo){
return 11;
}
JSLint has no problems with these changes, but clearly they will cause me some trouble later. What would like to do is something like this:
addTwoNumbers: function(numberOne, numberTwo){
/* jslint fail */
return 11;
}
This way when I run JSLint before committing I will see that I have done something I probably shouldn't.
Alternately, if I am planning on committing the code (bad idea) and coming back to it in a couple weeks, I want to be warned frequently by JSHint.
I know that I can use the "Unexpected TODO comment" but my team (me included) uses TODO very liberally. Another method would be preferred.
More info on: Unexpected TODO comment
this is a coding style and not a language fault, and recently JSHint has taken the decision to not implement coding style options in the linter.
I'm not sure of the state of development, but it may be/become possible to write extensions to JSHint to enforce one's own coding style.
Though, what you're asking is done since programming and editors exist:
addTwoNumbers: function(numberOne, numberTwo){
return 11; // TODO bad implementation, change it!
}
and have your editor highlight the comment in yellow and red, add a /!\ in the line number column, and have it list it along with the warnings of your linter!
But that's not JSHint's job, or even a linter's job to check that kind of things!
I am leaving this here partly as a note to myself and partly for anyone else who has this issue.
If you are using grunt to invoke jslint, you can also use grunt-todo. This allows you to define tags in your project and then it will list the tags on build/grunt. It has some built in tags by default and you can add your own. I think you should even be able to configure your release build to fail if there are specific tags in the code base.
How do you stop files from being watched?
I have not seen the method in the docs which seems a bit odd to me.
It's not a gulp thing. Gulp is just running as a never ending process.
The way to abort a process is Ctrl+C.
According the official document. you can using returned stream method to stop it.
let watchStream = gulp-watch(paths, function(){})
watchStream.close()
If you are using Visual Studio 'Package Manager Console' just press red square button inside that window.
I am not sure the user is going to install the plug in. They can choose not to install. I need to know information like, install complete, or the user choose not to install. Any ideas?
Thanks,
Grae
More context would be helpful in answering your question.
That said, if there's a particular plugin that you have in mind, you can do a post-install check* of simply trying to instantiate the object. This article has a pretty good description of what to do, but if you only care about IE and ActiveX plugins, then something like this should work well enough (untested):
function testPlugin(name)
{
if (ActiveXObject)
{
try
{
return !!(new ActiveXObject(name));
}
catch (err) {}
}
return false;
}
and you could use that function to test whether or not, say, QuickTime is installed:
testPlugin('QuickTime.QuickTime');
*This will actually work at any time, not just after a possible plugin install