{"_id":"@codecontrol/cross-var","name":"@codecontrol/cross-var","dist-tags":{"latest":"1.1.1"},"versions":{"1.1.1":{"name":"@codecontrol/cross-var","version":"1.1.1","description":"> An updated fork of [`cross-var`](https://github.com/elijahmanor/cross-var) by Elijah Manor.","main":"index.js","bin":{"cross-var":"index.js"},"scripts":{"test":"echo \"Error: no test specified\" && exit 0"},"author":{"name":"Forked by Codecontrol","url":"original: Elijah Manor"},"license":"MIT","keywords":["npm-scripts"],"repository":{"type":"git","url":"git+https://github.com/Codecontrol-Oy/cross-var.git"},"bugs":{"url":"https://github.com/Codecontrol-Oy/cross-var/issues"},"dependencies":{"@babel/core":"^7.27.4","@babel/preset-env":"^7.27.2","@babel/preset-flow":"^7.27.1","@babel/preset-stage-0":"^7.8.3","@babel/register":"^7.27.1","cross-spawn":"^7.0.6","exit":"^0.1.2"},"gitHead":"6e097f2be5d4b0013c3dea2c825991bcda953307","homepage":"https://github.com/Codecontrol-Oy/cross-var#readme","_id":"@codecontrol/cross-var@1.1.1","_nodeVersion":"19.7.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-cK+AjYeJcYJ3wC2CyBJbPD5brRoWS+Y0fr+l8zg0WOxf1rfOduc7ilhr2Jl1bLCWkXGCFv/t/5WMex8zV3iLYA==","shasum":"6dc8cb1b3d430e1945b7e71c093ef707daef7bd0","tarball":"https://registry.npmjs.org/@codecontrol/cross-var/-/cross-var-1.1.1.tgz","fileCount":5,"unpackedSize":7693,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEzEpnVMhZYCXPKaj05z0MbY8yPeE8wyNoWPy9QxXjjYAiEAhTgjdNHOQ8Ghz+s8ELEjwux92zPUH+wMWxLSlABSTBU="}]},"_npmUser":{"name":"miikaforma","email":"miika.forma@codecontrol.fi"},"directories":{},"maintainers":[{"name":"toniiltanen","email":"toni.iltanen@codecontrol.fi"},{"name":"miikaforma","email":"miika.forma@codecontrol.fi"},{"name":"sami-lindgren","email":"sami.lindgren@codecontrol.fi"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cross-var_1.1.1_1749466376903_0.16390624231160134"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-09T10:52:56.767Z","1.1.1":"2025-06-09T10:52:57.062Z","modified":"2025-06-09T10:52:57.439Z"},"maintainers":[{"name":"toniiltanen","email":"toni.iltanen@codecontrol.fi"},{"name":"miikaforma","email":"miika.forma@codecontrol.fi"},{"name":"sami-lindgren","email":"sami.lindgren@codecontrol.fi"}],"description":"> An updated fork of [`cross-var`](https://github.com/elijahmanor/cross-var) by Elijah Manor.","homepage":"https://github.com/Codecontrol-Oy/cross-var#readme","keywords":["npm-scripts"],"repository":{"type":"git","url":"git+https://github.com/Codecontrol-Oy/cross-var.git"},"author":{"name":"Forked by Codecontrol","url":"original: Elijah Manor"},"bugs":{"url":"https://github.com/Codecontrol-Oy/cross-var/issues"},"license":"MIT","readme":"# `@codecontrol/cross-var` – Cross-platform variable usage in npm scripts\n\n> An updated fork of [`cross-var`](https://github.com/elijahmanor/cross-var) by Elijah Manor.\n\n[![NPM](https://nodei.co/npm/@codecontrol/cross-var.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/@codecontrol/cross-var/) \n[![NPM](https://nodei.co/npm-dl/@codecontrol/cross-var.png?months=9&height=3)](https://nodei.co/npm/@codecontrol/cross-var/)\n\n[![npm version](https://img.shields.io/npm/v/@codecontrol/cross-var.svg)](https://www.npmjs.com/package/@codecontrol/cross-var)\n[![npm downloads](https://img.shields.io/npm/dm/@codecontrol/cross-var.svg)](https://www.npmjs.com/package/@codecontrol/cross-var)\n[![npm downloads](https://img.shields.io/npm/dt/@codecontrol/cross-var.svg)](https://www.npmjs.com/package/@codecontrol/cross-var)\n[![license](https://img.shields.io/npm/l/@codecontrol/cross-var.svg)](https://github.com/codecontrol-fi/cross-var/blob/main/LICENSE)\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\n## Fork Notes\n\nThis is a maintained fork of the original [`cross-var`](https://github.com/elijahmanor/cross-var) project.\n\n**Changes in this fork:**\n\n- Updated dependencies to modern versions\n- Published as `@codecontrol/cross-var` on npm\n- Ensured compatibility with current Node.js environments\n\nOriginal author: Elijah Manor\n","readmeFilename":"README.md","_rev":"1-f0ea6c63d1b5c2ca913b7be0efdb5f97"}