Get changed file path via Grunt and use it to pass as an argument for another task - gruntjs

It's interesting how can I get file path which file has changed via Grunt. Then use last changed file as argument for another task.
Actually I want to get file path and send it to grunt-shell to do some x [filename] command.

I've done working solution with this gruntfile: https://gist.github.com/nikoloza/515f4d4cac656cbe2594
Someone may find it useful.

Related

Azure databricks %run magic command unable to find file path

I have 2 notebooks under the root folder in my workspace. Calling one notebook from the other with %run magic cmd returns error saying file path not found. This is my command:
%run /Users/name#comp.com/notebookB $arg1=val1 $arg2=val2
Found the solution, turns out the run command needs to be in a cell all by itself - no other code and no comments. I have seen some solutions online say that the cell should not contain any comments, but turns out it should not contain any other code either.
It's really better to use relative names instead of absolute (starting with /):
If both notebooks are in the same folder, then you can refer to another using syntax ./notebook_name
If another is in the folder above, then use ../notebook_name
if another is in the subfolder, then use subfolder/notebook_name

Reading Error when trying to compile SASS in vs code

I installed SASS on my machine via path ( environment variables ).
I can access help and other options(version etc.) but whenever I initiate
`--watch styles.scss:styles.css`
I get the following error :
`Error reading styles.scss: Cannot open file.`
I checked the documentation but to no avail. I get the same error when trying to get more information via
--trace styles.scss:styles.css
I found the reason of my self-inflicted error.
When you initiate
--watch styles.scss styles.css
make sure you add the directory in case you placed your css styles in an external folder
--watch css/styles.scss css/styles.css
Wow, thanks for your description of your self-inflicted error. It solved my problem of not seeing any output for half an hour. I had given the full path for the input file (path from the folder where the command runs to the input file), but had taken that the path of the output file would be relative to the input file (ie: the path from the input file to the output file), but it should also be the full path to the output file (path from the folder where the command runs to the output file). In fact easier, but if one has a wrong expectation in one's head it can take a long time to realize. Your description put me on the right track!

How to rsync when destination file is with attribute i (shown in lsattr)

When I run
rsync -azV /source_dir /dest_dir
I find one file with i attribute in dest_dir is not synced, with error like:
error: rename dest_dir/.file.3dsx3x to dest_dir/file fails: Operation Not permitted
I understand that the file with i is not replaceable. But if I really want to sync it, what could I do? Is there any way for rsync command to do it?
Thanks.
No, the only option rsync has for attributes is -X, to copy them, and even that doesn't attempt to create files with the i attribute.
I think you'll just have to remove the attribute for the duration of the sync.

xquery - file test

My xquery script opens several files. One of the files is sometimes missing. I need to test whether the file exists before I try to open it. (something like -f in bash or perl).
Is it possible?
Use this standard XPath 2.0 function:
doc-available(yourURL)

Location of configuration in unix program

I want to write a unix/linux program, that will use a configuration file.
My problem is, where should I put the location of the file?
I could "hardcode" the location (like /etc) into the program itself.
However, I would like it, if the user without privileges could install it (through make) somewhere else, like ~.
Should the makefile edit the source code? Or is it usually done in a different way?
Create some defaults:
/etc/appname
~/.appname
Then if you want to allow these to be overridden have your application inspect an environment variable. e.g.
$app_userconfig
$app_config
Which would contain an override path/filename.
Lastly add a command line option that allows a config to be specified at runtime, e.g.
-c | --config {filename}
It is common to use a series of places to get the location:
Supplied by the user as a command line argument (i.e. ./program -C path/to/config/file.cfg).
From an environment variable (char *path_to_config = getenv("PROGRAMCONFIG");).
Possibly look for a user specific or local version (stat("./program.cfg") or build up a strig to specify either "$HOME/.program/config.cfg" or "$HOME/.program.cfg" and stat that).
Hardcoded as a backup (stat("/etc/program/config.cfg",...)).
keeping a global config file under /etc/prgname is a standard. Also allowing a .local config file for individual users that will override the global settings would allow each user to personalize the program to their preference.
As skaffman says, the canonical locations for things like config files are specified in FHS. There appears to be a convention that a program will read a config file from the directory from which it is run as an alternative to the one in the hard-coded location. You may wish to consider adding a command-line switch that allows a user to specify an alternative config file location, as well.
The makefile shouldn't modify the source directly, but it can pass a folder path/name to the compiler through the -D option. One way to handle it would be to #define something like DEFAULT_PATH to be the default installation path. If the user wants to define a path, the makefile would add -DUSER_PATH=whatever to the compiler options. You would write your code to use USER_PATH if it exists, and DEFAULT_PATH otherwise.

Resources