Reputation: 2409
The goal is to delete the public folder and then to recreate it before building the application.
This should work also if the folder does not exist yet.
I have this script in package.json:
"scripts": {
"prebuild": "rm -rf public && mkdir public"
}
it works nicely on mac and linux
how can I get it to work on Windows, preferably in powershell?
Upvotes: 1
Views: 2039
Reputation: 2409
this here seems to work best:
"scripts": {
"prebuild": "rmdir /Q /S public && mkdir public"
}
only problem: an error occurs if the folder "public" does not exist yet
Upvotes: 2
Reputation: 801
if (test-path public) { rmdir public; mkdir public}
Or
if (test-path public) { Remove-Item public; Create-Item -Directory public}
Or
mkdir blank;robocopy /MIR blank public;rmdir blank
Or
Create-Item -Directory blank; robocopy /MIR blank public; Remove-Item blank
I think the last one is the most appropriate. Of course 'public' will probably need to be set as a relative or absolute path.
And using the linux aliases probably only works in the powershell shell or gui. To see the PowerShell equivalent of most commands, just Get-Alias <command>
.
Upvotes: 0