''BUILD_PATH' Creates Directory but Files are Empty

I am trying to automate pushing my compiled code to my development server host.

My plan is to build the code from react-scripts and push it to my server's bare repo. But since the code itself is also under source control, I want the folder to be out of the source's main git.

I have set the BUILD_PATH option in my react-scripts (Windows environment):

"scripts": {
  ...
  "buildStage": "set BUILD_PATH=../buildStage && react-scripts build"
}

When I run "buildStage" it compiles, and I can navigate to it in Windows File Explorer, the compiled file tree is there, but the folder size is 0 bytes.

Similarly, if I try to navigate there using Powershell, I get an error:

<user>: cd ../buildStage
cd : Cannot find path 'C:\Users\user\Documents\Code\src\buildStage' because it does not exist.
At line:1 char:1
+ cd x
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\user...s\Code\src\buildStage:String) [Set 
   -Location], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

So apparently it doesn't find the build folder, despite having just built the code into it.

Has anyone experienced this and knows of a way through this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source