Repository: yargs/yargs
Pull request #1159 (2018-06-22 21:48:22)

chore: cache node_modules


Patch:
diff --git a/.travis.yml b/.travis.yml
index fbc7109..99187a7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,11 @@ os:
 
 after_success: npm run coverage
 
+cache:
+  directories:
+    - "node_modules"
+
 node_js:
-  - "4"
   - "6"
-  - "node"
+  - "8"
+  - "10"
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..38a3bf2
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,46 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at aorinevo@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/
diff --git a/appveyor.yml b/appveyor.yml
index 79621eb..45b6ef2 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -3,16 +3,16 @@
 # Test against these versions of Node.js.
 environment:
   matrix:
-    - nodejs_version: "4"
     - nodejs_version: "6"
-    - nodejs_version: "7"
+    - nodejs_version: "8"
+    - nodejs_version: "10"
 
 # Install scripts. (runs after repo cloning)
 install:
   # Get the latest stable version of Node 0.STABLE.latest
   - ps: Install-Product node $env:nodejs_version
   # Typical npm stuff.
-  - npm i npm@5
+  - npm i -g npm@latest
   - npm install
 
 # Post-install test scripts.
@@ -22,6 +22,9 @@ test_script:
   - npm --version
   - cmd: npm t
 
+cache:
+  - node_modules
+
 os:
   - Default Azure
 
diff --git a/contributing.md b/contributing.md
index 74a09a0..81ee8c8 100644
--- a/contributing.md
+++ b/contributing.md
@@ -16,54 +16,3 @@ Me hearties, we would love to have you contribute to yargs!
   * look through our extensive test suite in `/test` to get an idea for how
     to write unit-tests for this codebase.
 5. make sure you are comfortable with the Code of Conduct outlined below.
-
-## Contributor Code of Conduct
-
-As contributors and maintainers of this project, and in the interest of
-fostering an open and welcoming community, we pledge to respect all people who
-contribute through reporting issues, posting feature requests, updating
-documentation, submitting pull requests or patches, and other activities.
-
-We are committed to making participation in this project a harassment-free
-experience for everyone, regardless of level of experience, gender, gender
-identity and expression, sexual orientation, disability, personal appearance,
-body size, race, ethnicity, age, religion, or nationality.
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery
-* Personal attacks
-* Trolling or insulting/derogatory comments
-* Public or private harassment
-* Publishing other's private information, such as physical or electronic
-  addresses, without explicit permission
-* Other unethical or unprofessional conduct
-
-Project maintainers have the right and responsibility to remove, edit, or
-reject comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct, or to ban temporarily or
-permanently any contributor for other behaviors that they deem inappropriate,
-threatening, offensive, or harmful.
-
-By adopting this Code of Conduct, project maintainers commit themselves to
-fairly and consistently applying these principles to every aspect of managing
-this project. Project maintainers who do not follow or enforce the Code of
-Conduct may be permanently removed from the project team.
-
-This Code of Conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community.
-
-Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported by contacting a project maintainer at ben@npmjs.com. All
-complaints will be reviewed and investigated and will result in a response that
-is deemed necessary and appropriate to the circumstances. Maintainers are
-obligated to maintain confidentiality with regard to the reporter of an
-incident.
-
-
-This Code of Conduct is adapted from the [Contributor Covenant][homepage],
-version 1.3.0, available at
-[http://contributor-covenant.org/version/1/3/0/][version]
-
-[homepage]: http://contributor-covenant.org
-[version]: http://contributor-covenant.org/version/1/3/0/
diff --git a/docs/api.md b/docs/api.md
index 85af995..d18d8f9 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -813,6 +813,20 @@ var yargs = require("yargs")(['--info'])
   .argv
 ```
 
+<a name="scriptName"></a>.scriptName($0)
+------------------
+
+Set the name of your script ($0). Default is the base filename executed by node (`process.argv[1]`)
+
+Example:
+
+```js
+var yargs = require("yargs")
+  .scriptName("my-script")
+  .help()
+  .argv
+```
+
 <a name="showHidden"></a>.showHidden()
 -----------------------------------------
 .showHidden([option | boolean])
diff --git a/example/help.js b/example/help.js
index c499a1d..a290809 100644
--- a/example/help.js
+++ b/example/help.js
@@ -3,7 +3,7 @@ var yargs = require('../index');
 var argv = yargs
   .usage('This is my awesome program\n\nUsage: $0 [options]')
   .help('help').alias('help', 'h')
-  .version('1.0.1', 'version').alias('version', 'V')
+  .version('version', '1.0.1').alias('version', 'V')
   .options({
     input: {
       alias: 'i',
diff --git a/yargs.js b/yargs.js
index da1a4bd..c2ac0fe 100644
--- a/yargs.js
+++ b/yargs.js
@@ -37,6 +37,11 @@ function Yargs (processArgs, cwd, parentRequire) {
 
   if (!cwd) cwd = process.cwd()
 
+  self.scriptName = function scriptName (scriptName) {
+    self.$0 = scriptName
+    return self
+  }
+
   self.$0 = process.argv
     .slice(0, 2)
     .map((x, i) => {


Test patch:
diff --git a/test/usage.js b/test/usage.js
index 8907e35..6cfad3e 100644
--- a/test/usage.js
+++ b/test/usage.js
@@ -1232,6 +1232,26 @@ describe('usage tests', () => {
     })
   })
 
+  describe('scriptName', () => {
+    it('should display user supplied scriptName', () => {
+      const r = checkUsage(() => yargs(['--help'])
+        .scriptName('custom')
+        .command('command')
+        .parse()
+      )
+      r.logs.join('\n').split(/\n+/).should.deep.equal([
+        'custom [command]',
+        'Commands:',
+        '  custom command',
+        'Options:',
+        '  --help     Show help                                                 [boolean]',
+        '  --version  Show version number                                       [boolean]'
+      ])
+      r.errors.should.have.length(0)
+      r.exit.should.equal(true)
+    })
+  })
+
   it('should succeed when rebase', () => {
     rebase(['home', 'chevex'].join(path.sep), ['home', 'chevex', 'foo', 'bar', 'baz'].join(path.sep)).should.equal(['foo', 'bar', 'baz'].join(path.sep))
     rebase(['home', 'chevex', 'foo', 'bar', 'baz'].join(path.sep), ['home', 'chevex'].join(path.sep)).should.equal(['..', '..', '..'].join(path.sep))