Webstorm File Watchers repeats calling batch file for ever - javascript

I am using File Watchers within Webstorm for calling a batch file.
This batch file contains an Ant call command like this:
call ant "clean" "debug" "compress" -f C:\Users\cm\workspace2\Games\jsfiles\PokerGame\build\build.xml
File Watchers triggers every time I save changed js files and does not stop it calls and for ever.
The picture shows my configuration for File Watcher in Webstorm.
What am I doing wrong?

just a supposition: the IDE sees the .js files generated by ant (as a result of 'compress' target running) and, as it watches .js files, runs the watcher again and again... Try excluding the directory where your minified files are created from watcher scope - create a new scope (Settings/scopes) with this folder excluded and then set this scope to your file watcher

Related

How to know the directory from which a script is called?

I'm running a script defined in my package.json defined like "generate": "node generators/index.js"and it simply runs when I run npm run generate.
My script generates a copy from a template folder that is in the root of my project, the thing is that it's creating the template copies to the same root folder, and what I want it to do is to create the copy in the folder where I'm currently in the terminal.
Eg. I am in bin/data I run my command and I want to create a copy of the folder from my template stored in templates/state so that the copy of this template will be created in bin/data/state
I was trying to use the proccess.cwd() method but it creates all in the root path as this is a method that is called in a script stored in root folder.
How can I achieve this?
Use (process.env.PWD) inside the node script.

Cannot call function after minification

I am developing a web application in Laravel. Primarily, I had kept my js codes in public directory and everything was working. But later, I had planned to move them to the resources directory and minify them.
Now, the problem is the functionalities, those are getting triggered by the JQuery are running well. But the functions, I am calling from the blade template are getting failed as the js is minified.
Here, I need some solution without moving my JS codes to the public directory.
I had run NPM to minify the JS.
npm run prod
After this, the code is failing to call a function.
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
mix.js('resources/js/validation.js', 'public/js');
Actually, I found the answer.
npm run prod actually references all method and variable declaration and calling functions with minimum characters to minify and optimize them.
When I am calling one function from HTML, that function calling name is not compiled in HTML, but changed in JS file, turning out to be not found.
I have moved my function call with DOM events to JS files to make them in the same stream

Ember: How do I add a file into the treeForAddon after postBuild?

I have a case where I am using node-sass functions to generate a JS file after sass has completed compiling. I am outputting the file into the addon/utils directory; however, the file is not being picked until the project is built the second time.
I feel this would easily be solved if I ran SASS first and then compile the JS next (after trees have been updated with the new JS file), but I can't find anything that does that.
Any suggestions on how I could make this work?

Launch Gulp Watch for JS and detect current folder has changed

I need to minimize the number of gulp's command from my gulpfile.
This is my JS folders
js/
templates/
t-01/
t-02/
[...]
t-xxx/
My gulp task for JS (with livereload)
gulp.task('da-js', function() {
gulp.src([
'js/templates/**/*.js',
'!js/templates/**/*.min.js'
])
.pipe(concat('app.min.js'))
.pipe(gulp.dest('js/templates'))
.pipe(livereload());
});
This task is global the destination folder is templates but I want to detect the current folder of js files like is :
I'm changing js in /templates/t-01/
gulp.watch is launching
app.min.js is generating only in this folder t-01
I know the gulp.dest is not correct to target current folder but I don't know how to do this.
Thank you for your help :)
You can use gulp's watch method to monitor a folder with JS files for updates and run a series of tasks in response to some change.
gulp.task('watch-files', function() {
gulp.watch('js/templates/**/*.js', ['da-js']);
});
Here we're watching over all the JS files in templates and all it's sub-folders and running your file concatenation task (da-js) for every update. Now that we're executing the same task, your app.min.js folder will be generated in your templates folder even when you change templates/t-01/some.js.
With the watch-files task defined in your gulpfile.js, you can simply run gulp watch-files command which will start monitoring your files.

What is the difference between JS files in dist/ folder and the one in root?

I am totally new to NodeJS and I wonder what's the difference between those two.
For example, in this project (https://github.com/fikriauliya/hipku), we have index.js and dist/hipku.js. They are similar except the last line:
module.exports = publicMethods; vs return publicMethods;
I guess dist/hipku.js is generated from index.js? How is it generated and why does it need to be generated?
Things in the dist folder are usually the product of building from index.js in this case. You'll notice it gets minified, and that folder would eventually be used on production sites. If you look at the package.json file, you'll notice that index.js is the main file, so if you're doing any edits, that would be the place to do so.
It depends on how you want to use this package, in browser or server side.
server side
index.js is the entry of NPM package. When you do require('hipku'), actually NodeJS locates the file module node_modules/hipku and run index.js ends up with the object adhere to module.exports
browser
Just load dist/hipku.js into your browser by <script>, it will register hipku into your global namespace, then you can use it's API.

Categories

Resources