0

package.json:

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "folders": {
    "plugin": {
      "dist": "\"/Users/User/Google Drive/App/Dist/plugin\""
    }
  },
  "scripts": {
    "remove_shared_dist": "rm -rf $npm_package_folders_plugin_dist"
  }
}

I want to remove the following folder: /Users/User/Google Drive/App/Dist/plugin.
I've wrapped its path with \" to make the shell accept folder names with space; but it only prints

rm -rf $npm_package_folders_plugin_dist

and does absolutely nothing.
If I run rm -rf "/Users/User/Google Drive/App/Dist/plugin" in terminal - it removes the folder as expected.
I'm on macOS

avalanche1
  • 3,154
  • 1
  • 31
  • 38
  • 1
    I don't think this is the primary problem, but in shell syntax you should put double-quotes around the variable reference (i.e. `"remove_shared_dist": "rm -rf \"$npm_package_folders_plugin_dist\""`), and *not* in the variable's value (see [here](https://stackoverflow.com/questions/12136948/why-does-shell-ignore-quotes-in-arguments-passed-to-it-through-variables) for details). – Gordon Davisson Sep 01 '19 at 02:46
  • tried that; unfortunately, in that case `npm run` environment doesn't recognise `$npm_package_folders_plugin_dist` as a variable, but as a string – avalanche1 Sep 01 '19 at 18:09

1 Answers1

1

@Gordon Davisson's comment hinted me to the right direction.

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "folders": {
    "plugin": {
      "dist": "\"/Users/User/Google Drive/App/Dist/plugin\""
    }
  },
  "scripts": {
    "remove_shared_dist": "bash -c \"rm -rf $npm_package_folders_plugin_dist\""
  }
}
avalanche1
  • 3,154
  • 1
  • 31
  • 38