I have the following directories tree:
- client
- plugins
- plugin1
- plugin2
- plugin3
- widgets
- widget1
- widget2
- resources
- img
I need to copy all files from resources belonging to any particular plugin widget into one folder using grunt copy, so I'm using the following globbing pattern to find those files:
src: 'client/plugins/**/*/resources/img/*'
But it doesn't seem to be able to find them, so I guess the pattern is wrong. Where is my mistake?
I don't think you can use a specific directory after using the ** pattern because that already matches any subfolder. I think you'll need to be more specific:
src: 'client/plugins/*/widgets/*/resources/img/*'
If you can't use "widgets" exactly, then you'll need to find another alternative, maybe just using another /*/. You can find all of the globbing options in the node-glob Github repo README file. This includes things like anti-patterns if it comes to that.
Related
I want to sync two different directories using the dirsync module, but exclude some specific folders.
In the documentation (https://pypi.org/project/dirsync/) it says the exclude need to be a regex pattern but I cant quite make it work.
For example, lets say we have these directories
c:\folder1\folder2
c:\folder1\folder3
d:\folder1\
I want to sync c:\folder1\ with d:\folder1\ and exclude folder3, so basically the folder c:\folder1\folder2 will be copied and created in d:\
from dirsync import sync
src = r'c:\folder1'
dst = r'd:\folder1'
sync(src, dst, 'diff', exclude='^folder3')
this won't work and I can't quite understand why.
The exclude option expects a list of regexp:
exclude=['^folder3']
I am retrieving a list of items in a directory with fs.readdirSync(somePath). In this directory there are subdirectories or links to other directories.
/somePath/
- P13
- P31.lnk
- P46
- someOther.file
In each of the product folders there is a config.xml which I need to retrieve. I have filtered/mapped the list to either get ['P13', 'P31.lnk', 'P46'] or ['P13', 'P31', 'P46']. I need the real path to every config file (to read it with fs.readFileSync).
For P13 and P46 this is easy, but I'm struggling with P13. I tried several things with fs.realpathSync():
fs.realpathSync('/someDir/P13/config.xml')
fs.realpathSync('/someDir/P13.lnk')
fs.realpathSync('/someDir/P13')
Which all yield either an error or just the path of the link file, but don't follow the link. Is there any way in JS/Node to follow these links through? I need to do this on Windows, if this makes a difference.
Cheers and thanks
I'm setting up a new algorithm and I want to share it on another computer. How can I set paths with only the folder name, for example.
I've tried to use the function os.chdir(path), but I don't achieve to reach my folder when I'm not using a 'root path' like C:/../../folder.
os.chdir(../folder_name)
By doing os.chdir(../folder_name), you are referring to the parent dir of the current directory.
You probably are looking for the os.chdir(./folder_name), with one dot? This is the current directory, where your script stands.
More here: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
Update: After clarification in the comments, you want to refer to folder_name from one of its subfolder (/folder_name/library). Then it is indeed .. that you should use, but .. only:
os.chdir(..)
I am writing a (actually my first) largish program in Haskell and am trying to break up my program into modules, so that it might be easier to maintain. In Haskell, the module names seem to be dependent upon the directory structure. This is perfectly fine till I have to embed another layer of directory structure for the program. Ill give a very simple example below:
Let us say that we are starting out with a Haskell program with the following directory structure.
Names in [square brackets] represent directories,
names in {curly braces} represent modules,
names in (normal brackets) represent file names associated within the modules
[src]
- (Main.hs) {Main}
- (PRBS.hs) {PRBS}
- [Hardware]
- (DataDef.hs) {Hardware.DataDef}
- (ShiftRegister.hs) {Hardware.ShiftRegister}
This is all fine. I can import everything I want wherever I want it. However, now say I want to create another level of abstraction, like so:
[src]
- (Main.hs) {Main}
- [Firmware]
- (PRBS.hs) {Firmware.PRBS}
- [Hardware]
- (DataDef.hs) {Firmware.Hardware.DataDef}
- (ShiftRegister.hs) {Firmware.Hardware.ShiftRegister}
Notice now that the names of all modules in Hardware have changed. I now have to change the module names within each file, and in all the other files where the files are imported. The three files I have shown in just an example. If the directory structure ends up having hundreds of files with tens of embedded directories, then it might become impossible to maintain code. Furthermore, if at any point, I want to copy a directory (and its subdirectories at a particular point in the current directory system), I need to figure out all the previous directories that come before it, and manually change the module names within each file.
Since Haskell is used in several large projects, I am very certain that I am missing something here. Any help in getting me out of this quagmire will be greatly appreciated!
If you have perl and bash and find and all that, you can do something like this:
find Firmware/Hardware/ -name '*.hs' -exec perl -i.bak -pe \
's/^module (Hardware\.\S+)/module Firmware.$1/' \
{} \;
diff Firmware/Hardware/DataRef.hs{,.bak}
I'm trying to store whole the output of my build, this includes some empty folders. These aren't included by the artefact mechanism in teamcity:
What doesn't work:
OAR\=> OAR.zip
OAR->OAR.zip
OAR
Inside of OAR i have a folder structure that needs to be stored. I know i could put a placeholder file in each but that is not the answer i'm after. Otherwise ill have to zip it myself?
Unfortunately TeamCity, by design, searches for files and uploads them as artifacts which means that empty folders are never included. Given the open and very old issue in the TeamCity tracker I doubt they are going to fix it any time soon.
I would recommend zipping the folder yourself, that is the approach we have taken. How you implement that depends on the build technology you are using. For example, if you are building using Nant you could add the zip task to your build, there are similar options for MSBuild and Ant.
If you don't want to rely on the build performing the zip I would recommend installing 7zip on your build agents and using the command line to perform the zip. Just remember if you want 7zip to include empty directories use * as the wildcard rather than *. * like so:
7z a -r OAR.zip *
Technically you could use powershell to do the zipping, which would be better than having to install something on your agents. I haven't tried this option myself.
Apologies for not linking all my references above. Apparently, and understandably so, I need at least 10 reputation to post more than 2 links.