{"_id":"@appicanis/cross-var","name":"@appicanis/cross-var","dist-tags":{"latest":"1.1.1"},"versions":{"1.1.1":{"name":"@appicanis/cross-var","version":"1.1.1","description":"[![NPM](https://nodei.co/npm/cross-var.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/cross-var/)  [![NPM](https://nodei.co/npm-dl/cross-var.png?months=9&height=3)](https://nodei.co/npm/cross-var/)","main":"index.js","bin":{"cross-var":"index.js"},"scripts":{"test":"echo \"Error: no test specified\" && exit 0"},"author":{"name":"Elijah Manor"},"license":"MIT","keywords":["npm-scripts"],"repository":{"type":"git","url":"git+https://github.com/elijahmanor/cross-var.git"},"bugs":{"url":"https://github.com/elijahmanor/cross-var/issues"},"dependencies":{"@babel/core":"^7.20.12","@babel/preset-env":"^7.20.2","@babel/preset-flow":"^7.18.6","@babel/preset-stage-0":"^7.8.3","@babel/register":"^7.18.9","cross-spawn":"^7.0.3","exit":"^0.1.2"},"gitHead":"6ae35d8f1832ea9f99b124b0957718daafcc0ab7","homepage":"https://github.com/elijahmanor/cross-var#readme","_id":"@appicanis/cross-var@1.1.1","_nodeVersion":"16.15.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-cXzD/oi4gElE0MaDd0j8ImZxNz/+MFJX5eRvthSVAPIug/qBJcbCoRfLmNXyB0VirqxdKyau2mXwpwlY4HlxlQ==","shasum":"b4a9214faf06cf60a0c6cca568e515c3d73570cc","tarball":"https://registry.npmjs.org/@appicanis/cross-var/-/cross-var-1.1.1.tgz","fileCount":5,"unpackedSize":8350,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCdso2zly3ItUdlaJkhQSKqjHsaFiM5XIsTRHQOf+H+YgIhAI3P06xT1gOOT01k7ZFt0H1BaZ2unNygh2oBcR7lgdSR"}]},"_npmUser":{"name":"appicanis","email":"radovan.obal@appicanis.si"},"directories":{},"maintainers":[{"name":"appicanis","email":"radovan.obal@appicanis.si"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cross-var_1.1.1_1686147876574_0.23786750583330996"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-07T14:24:36.511Z","1.1.1":"2023-06-07T14:24:36.811Z","modified":"2023-06-07T14:24:36.977Z"},"maintainers":[{"name":"appicanis","email":"radovan.obal@appicanis.si"}],"description":"[![NPM](https://nodei.co/npm/cross-var.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/cross-var/)  [![NPM](https://nodei.co/npm-dl/cross-var.png?months=9&height=3)](https://nodei.co/npm/cross-var/)","homepage":"https://github.com/elijahmanor/cross-var#readme","keywords":["npm-scripts"],"repository":{"type":"git","url":"git+https://github.com/elijahmanor/cross-var.git"},"author":{"name":"Elijah Manor"},"bugs":{"url":"https://github.com/elijahmanor/cross-var/issues"},"license":"MIT","readme":"# `cross-var`\n\n[![NPM](https://nodei.co/npm/cross-var.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/cross-var/) \n[![NPM](https://nodei.co/npm-dl/cross-var.png?months=9&height=3)](https://nodei.co/npm/cross-var/)\n\n[![npm version](https://img.shields.io/npm/v/cross-var.svg)](https://www.npmjs.com/package/cross-var)\n[![npm license](https://img.shields.io/npm/l/cross-var.svg)](https://www.npmjs.com/package/cross-var)\n[![npm download](https://img.shields.io/npm/dm/cross-var.svg)](https://www.npmjs.com/package/cross-var)\n[![npm download](https://img.shields.io/npm/dt/cross-var.svg)](https://www.npmjs.com/package/cross-var)\n[![Package Quality](http://npm.packagequality.com/shield/cross-var.svg)](http://packagequality.com/#?package=cross-var)\n[![Inline docs](http://inch-ci.org/github/elijahmanor/cross-var.svg?branch=master)](http://inch-ci.org/github/elijahmanor/cross-var)\n[![star this repo](http://githubbadges.com/star.svg?user=HansHammel&repo=cross-var&style=flat&color=fff&background=007ec6)](https://github.com/elijahmanor/cross-var)\n[![fork this repo](http://githubbadges.com/fork.svg?user=HansHammel&repo=cross-var&style=flat&color=fff&background=007ec6)](https://github.com/elijahmanor/cross-var/fork)\n\n[![david dependency](https://img.shields.io/david/elijahmanor/cross-var.svg)](https://david-dm.org/elijahmanor/cross-var)\n[![david devDependency](https://img.shields.io/david/dev/elijahmanor/cross-var.svg)](https://david-dm.org/elijahmanor/cross-var)\n[![david optionalDependency](https://img.shields.io/david/optional/elijahmanor/cross-var.svg)](https://david-dm.org/elijahmanor/cross-var)\n[![david peerDependency](https://img.shields.io/david/peer/elijahmanor/cross-var.svg)](https://david-dm.org/elijahmanor/cross-var)\n[![npms score](https://badges.npms.io/cross-var.svg)](https://www.npmjs.com/package/cross-var)\n[![Known Vulnerabilities](https://snyk.io/test/github/elijahmanor/cross-var/badge.svg)](https://snyk.io/test/github/elijahmanor/cross-var)\n\n## Overview\n\nWhen using `npm scripts` it creates a lot of environment variables that are available for you to leverage when executing scripts.\n\nIf you'd like to take a look at all of the variables then you can run `npm run env` in your terminal. \n\n```\n> npm run env\n\nnpm_package_name=cross-var\nnpm_package_author_name=Elijah Manor\nnpm_package_version=1.0.0\n... lots more ...\n```\n\nNow you can use those environment variables in your `npm scripts` by referencing them like the following\n\n```\n{\n  \"name\": \"World\",\n  \"scripts\": {\n    \"//\": \"The following only works on Mac OS X/Linux (bash)\",\n    \"bash-script\": \"echo Hello $npm_package_name\"\n    \"//\": \"The following only works on a Windows machine\",\n    \"win-script\": \"echo Hello %npm_package_name%\"\n  }\n}\n```\n\n```\n> npm run bash-script\n\nHello World\n```\nHowever, this won't work on Windows... because it expects the variables to be surrounded by percent signs, so we can change our script just slightly.\n\n### `cross-var` to the Rescue!\n\nThe goal of `cross-var` is to let you use one script syntax to work either on a **Mac OS X/Linux (bash)** or **Windows**. Reference the [Usage]() documention below on how to use `cross-var` in your scripts.\n\n## Usage\n\n### Simple Commands\n\n```\n{\n  \"version\": \"1.0.0\",\n  \"config\": {\n    \"port\": \"1337\"\n  },\n  \"scripts\": {\n    \"prebuild\": \"cross-var rimraf public/$npm_package_version\",\n    \"build:html\": \"cross-var jade --obj data.json src/index.jade --out public/$npm_package_version/\",\n    \"server:create\": \"cross-var http-server public/$npm_package_version -p $npm_package_config_port\",\n    \"server:launch\": \"cross-var opn http://localhost:$npm_package_config_port\"\n  }\n}\n```\n\n### Complex Commands\n\n```\n{\n  \"version\": \"1.0.0\",\n  \"scripts\": {\n    \"build:css\": \"cross-var \\\"node-sass src/index.scss | postcss -c .postcssrc.json | cssmin > public/$npm_package_version/index.min.css\\\"\",\n    \"build:js\": \"cross-var \\\"mustache data.json src/index.mustache.js | uglifyjs > public/$npm_package_version/index.min.js\\\"\",\n  }\n}\n```\n\n## But What About!?!\n\n> Click on one of the following questions to reveal a detailed answer\n\n<details>\n\t<summary>Why don't you use `cross-env`?</summary>\n    `cross-env` is great for scripts that need a particular environment variable\nset, but isn't intended to fix cross-environment issues when using variables\ninside an `npm script` \n</details>\n\n<details>\n\t<summary>Why don't you use an external node file?</summary>\n    That is a fine solution to this problem, but if you would rather stick to\nstraight up `npm scripts`, then this is a good solution\n</details>\n\n<details>\n  <summary>Why don't you just use Windows 10 Ubuntu-based Bash shell?</summary>\nYes, if you can do that... then great! Windows 10’s version 1607 update, dubbed the “Anniversary Update”, has [intergrated a great bash shell](https://msdn.microsoft.com/en-us/commandline/wsl/about) that should allow you to run Linux software directly on Windows without any changes.\n\nHowever, if you want to support older Windows versions, then you might consider using `cross-env` or another approach to leverage environment variables in your scripts.\n</details>\n","readmeFilename":"README.md"}