Giter VIP home page Giter VIP logo

nodeprompt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

vokiel pjasiun zaak

nodeprompt's Issues

Modified files are displayed even after adding them to the index

(simple-upload fcec2ee M4 ?1) foo@bar /...foo/sf1/foo> git st
# On branch simple-upload
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   src/foo/PageBundle/Resources/public/css/subContact.css
#   modified:   src/foo/PageBundle/Resources/public/css/subHome.css
#   modified:   src/foo/PageBundle/Resources/views/Default/contact.html.twig
#   modified:   src/foo/PageBundle/Resources/views/Default/home.html.twig
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   src/foo/PageBundle/Resources/views/Default/fb.html.twig
#
no changes added to commit (use "git add" and/or "git commit -a")
(simple-upload fcec2ee M4 ?1) foo@bar /...foo/sf1/foo> git add -A
(simple-upload fcec2ee +1 M4) foo@bar /...foo/sf1/foo> 

After git add -A I would expect having only +5.

Test failing on Linux on branch v1.0

ENV

$ echo $BASH_VERSION
4.3.48(1)-release
$ npm -v
3.10.10
$ node -v
v6.11.1
$ git --version
git version 2.7.4

Failing tests log

$ npm test

> [email protected] test /home/vokiel/bin/nodeprompt
> mocha



  _getPath()
    ✓ returns path with default config (out of home)
    ✓ returns path with default config (in home)
    ✓ returns path with custom config

  _getStatus()
    ✓ works when no remote
    ✓ works when remote
    ✓ works when not clean
    ✓ works when detached or rebasing
    ✓ works when repo inited

  Nodeprompt
    constructor
      ✓ provides #model
      ✓ provides #styles
      config
        1) provides the default #config
        ✓ accepts a custom config (full)
        2) accepts a custom config (partial)

  print()
    3) generates PS1 when not Git repository
    4) generates PS1 when repository just inited
    5) generates PS1 when staged, not staged, deleted, untracked
    6) generates PS1 when detached
    7) generates PS1 while merging
    8) generates PS1 while rebasing
    9) generates PS1 while bisecting
    10) generates PS1 when branch is ahead
    11) generates PS1 when branch is behind
    12) generates PS1 when branch has diverged
    13) generates no PS1 when in .git directory
    14) generates no PS1 when in .git/* subfolder
    15) generates no PS1 when in .git/* subfolder (letter case)
    16) generates PS1 when in folder containing ".git" string

  styles
    ✓ are defined as functions


  12 passing (560ms)
  16 failing

  1) Nodeprompt
       constructor
         config
           provides the default #config:

      AssertionError: expected '$' to equal '>'
      + expected - actual

      -$
      +>
      
      at Context.it (test/nodeprompt.js:18:36)                                                                                                                                                                       

  2) Nodeprompt
       constructor
         config
           accepts a custom config (partial):

      AssertionError: expected '$' to equal '>'
      + expected - actual

      -$
      +>
      
      at Context.it (test/nodeprompt.js:48:36)                                                                                                                                                                       

  3) print()
       generates PS1 when not Git repository:

      AssertionError: expected 'undefined@undefined /path$ ' to equal 'user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +user@host /path> 
      
      at test (test/print.js:240:45)                                                                                                                                                                                 
      at Context.it (test/print.js:22:3)                                                                                                                                                                             

  4) print()
       generates PS1 when repository just inited:

      AssertionError: expected 'undefined@undefined /path$ ' to equal '(init) user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +(init) user@host /path> 
      
      at test (test/print.js:240:45)                                                                                                                                                                                 
      at Context.it (test/print.js:31:3)                                                                                                                                                                             

  5) print()
       generates PS1 when staged, not staged, deleted, untracked:

      AssertionError: expected 'undefined@undefined /path$ ' to equal '(master 44c100b +4 ?1) user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +(master 44c100b +4 ?1) user@host /path> 
      
      at test (test/print.js:240:45)                                                                                                                                                                                 
      at Context.it (test/print.js:42:3)                                                                                                                                                                             

  6) print()
       generates PS1 when detached:

      AssertionError: expected 'undefined@undefined /path$ ' to equal '(detached:master~1 a89567c) user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +(detached:master~1 a89567c) user@host /path> 
      
      at test (test/print.js:240:45)                                                                                                                                                                                 
      at Context.it (test/print.js:60:3)                                                                                                                                                                             

  7) print()
       generates PS1 while merging:

      AssertionError: expected 'undefined@undefined /path$ ' to equal '(merge:master<--test-head dcd0272 M1) user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +(merge:master<--test-head dcd0272 M1) user@host /path> 
      
      at test (test/print.js:240:45)                                                                                                                                                                                 
      at Context.it (test/print.js:73:3)                                                                                                                                                                             

  8) print()
       generates PS1 while rebasing:

      AssertionError: expected 'undefined@undefined /path$ ' to equal '(detached:master 76d59cb) user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +(detached:master 76d59cb) user@host /path> 
      
      at test (test/print.js:240:45)                                                                                                                                                                                 
      at Context.it (test/print.js:88:3)                                                                                                                                                                             

  9) print()
       generates PS1 while bisecting:

      AssertionError: expected 'undefined@undefined /path$ ' to equal '(detached:a/1234 3bf5643) user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +(detached:a/1234 3bf5643) user@host /path> 
      
      at test (test/print.js:240:45)                                                                                                                                                                                 
      at Context.it (test/print.js:101:3)                                                                                                                                                                            

  10) print()
       generates PS1 when branch is ahead:

      AssertionError: expected 'undefined@undefined /path$ ' to equal '(a/1234↑ 3bf5643) user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +(a/1234↑ 3bf5643) user@host /path> 
      
      at test (test/print.js:240:45)                                                                                                                                                                                 
      at Context.it (test/print.js:115:3)                                                                                                                                                                            

  11) print()
       generates PS1 when branch is behind:

      AssertionError: expected 'undefined@undefined /path$ ' to equal '(a/1234↓ 3bf5643) user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +(a/1234↓ 3bf5643) user@host /path> 
      
      at test (test/print.js:240:45)                                                                                                                                                                                 
      at Context.it (test/print.js:128:3)                                                                                                                                                                            

  12) print()
       generates PS1 when branch has diverged:

      AssertionError: expected 'undefined@undefined /path$ ' to equal '(a/1234↕ 3bf5643) user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +(a/1234↕ 3bf5643) user@host /path> 
      
      at test (test/print.js:240:45)                                                                                                                                                                                 
      at Context.it (test/print.js:141:3)                                                                                                                                                                            

  13) print()
       generates no PS1 when in .git directory:

      AssertionError: expected 'undefined@undefined /path$ ' to equal 'user@host /path> '
      + expected - actual

      -undefined@undefined /path$ 
      +user@host /path> 

      at test (test/print.js:240:45)
      at Context.it (test/print.js:154:3)

  14) print()
       generates no PS1 when in .git/* subfolder:

      AssertionError: expected 'undefined@undefined /path$ ' to equal 'user@host /path> '
      + expected - actual

      -undefined@undefined /path$
      +user@host /path>

      at test (test/print.js:240:45)
      at Context.it (test/print.js:177:3)

  15) print()
       generates no PS1 when in .git/* subfolder (letter case):

      AssertionError: expected 'undefined@undefined /path$ ' to equal 'user@host /path> '
      + expected - actual

      -undefined@undefined /path$
      +user@host /path>

      at test (test/print.js:240:45)
      at Context.it (test/print.js:192:3)

  16) print()
       generates PS1 when in folder containing ".git" string:

      AssertionError: expected 'undefined@undefined /path$ ' to equal '(master 44c100b +4 ?1) user@host /path> '
      + expected - actual

      -undefined@undefined /path$
      +(master 44c100b +4 ?1) user@host /path>

      at test (test/print.js:240:45)
      at Context.it (test/print.js:207:3)



npm ERR! Test failed.  See above for more details.

Going to .git folder crash prompt.

  1. Go to any git reposytory.
  2. cd .git/

Result:

/opt/nodeprompt/nodeprompt.js:72
data.branch = ( /^(.+?)(?:(?=.{2}| )|$)/g ).exec( branchLine )[ 1 ];
^
TypeError: Cannot read property '1' of null
at Object.NODEPROMPT.getStatus (/opt/nodeprompt/nodeprompt.js:72:67)
at Object.NODEPROMPT.getPS1 (/opt/nodeprompt/nodeprompt.js:151:9)
at Object. (/opt/nodeprompt/nodeprompt.js:185:35)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

Small performance issues

There's a noticeable delay after pressing enter and waiting for the prompt. I've checked and on my machine the scripts needs ~80-90ms to run on average mainly due to synchronously spawned child processes.

I've tried to change the logic to more asynchronous, but running few git tasks in parallel didn't helped me much, I was able to cut off only ~10-15ms of the script execution time. I've been thinking also about some kind of server running in the background and updating only changed parts of the prompt, but this would be hard to implement and maintain.

macOS: nodeprompt ignores starting directory set for new window/tab

In Terminal application options on mac, you can configure the if the new opened Terminal tab/window should open in the same working directory as the active tab:

Screenshot 2022-10-20 at 13 07 44

For some reason with nodeprompt this option doesn't work and the starting directory is always set to the user's home dir.

Below are two screencasts - in both all the terminal and shell options are the same. The only difference is . nodeprompt-enable-bash entry in .bash_profile.

Without nodeprompt - the new Terminal tab is opened in the same directory as the active tab:

Screen.Recording.2022-10-20.at.13.06.41.mov

With nodeprompt enabled - the new tab is opened in home directory:

Screen.Recording.2022-10-20.at.13.07.10.mov

TypeError: Cannot read property '1' of null

/home/vokiel/bin/nodeprompt/nodeprompt.js:72
                        data.branch = ( /^(.+?)(?:(?=\.{2}| )|$)/g ).exec( branchLine )[ 1 ];
                                                                                       ^
TypeError: Cannot read property '1' of null
    at Object.NODEPROMPT.getStatus (/home/vokiel/bin/nodeprompt/nodeprompt.js:72:67)
    at Object.NODEPROMPT.getPS1 (/home/vokiel/bin/nodeprompt/nodeprompt.js:151:9)
    at Object.<anonymous> (/home/vokiel/bin/nodeprompt/nodeprompt.js:185:35)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

The git status --porcelain sometimes is empty.

Error after moving to branch in which previous pwd does not exist

(t/11992-tests 2b02ed3 ?1) piotrus@dragonus /...cksource/ckeditor-dev/tests> git co master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.

node.js:815
    var cwd = process.cwd();
                      ^
Error: ENOENT, no such file or directory
    at Function.startup.resolveArgv0 (node.js:815:23)
    at startup (node.js:58:13)
    at node.js:906:3

Error inside `.git/*` subfolders

/usr/local/lib/node_modules/nodeprompt/bin/nodeprompt:72
                        data.branch = ( /^(.+?)(?:(?=\.{2}| )|$)/g ).exec( branchLine )[ 1 ];
                                                                                       ^
TypeError: Cannot read property '1' of null
    at Object.NODEPROMPT.getStatus (/usr/local/lib/node_modules/nodeprompt/bin/nodeprompt:72:67)
    at Object.NODEPROMPT.getPS1 (/usr/local/lib/node_modules/nodeprompt/bin/nodeprompt:152:9)
    at Object.<anonymous> (/usr/local/lib/node_modules/nodeprompt/bin/nodeprompt:199:35)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

/bin/bash --version
GNU bash, version 4.2.37(1)-release (x86_64-redhat-linux-gnu)
node --version
v0.12.2
git --version
git version 2.1.0.rc0.20.g583b61c

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.