Skip to content

Runs in cmd, but not in Git Bash... #47

Open
@curleb

Description

@curleb

Trying to poll a variety of collections across several local MongoDB instances, and I can only get some smaller collections to run successfully. Large collections are hitting some clearLine error, but only in the Bash shell. Runs okay...manually, under Windows:

`C:\Users\bcurley\AppData\Roaming\npm\node_modules\mongodb-schema\node_modules\progress\lib\node-progress.js:177
this.stream.clearLine();
^

TypeError: this.stream.clearLine is not a function
at ProgressBar.terminate (C:\Users\bcurley\AppData\Roaming\npm\node_modules\mongodb-schema\node_modules\progress\lib\node-progress.js:177:17)
at ProgressBar.tick (C:\Users\bcurley\AppData\Roaming\npm\node_modules\mongodb-schema\node_modules\progress\lib\node-progress.js:91:10)
at Stream. (C:\Users\bcurley\AppData\Roaming\npm\node_modules\mongodb-schema\bin\mongodb-schema:179:13)
at emitOne (events.js:96:13)
at Stream.emit (events.js:188:7)
at Stream.write (C:\Users\bcurley\AppData\Roaming\npm\node_modules\mongodb-schema\lib\stream.js:308:10)
at Stream.stream.write (C:\Users\bcurley\AppData\Roaming\npm\node_modules\mongodb-schema\node_modules\through\index.js:26:11)
at Stream.ondata (internal/streams/legacy.js:16:26)
at emitOne (events.js:101:20)
at Stream.emit (events.js:188:7)
=== `

`for i in $(mongo localhost:27017 --quiet --eval "db.adminCommand('listDatabases')"
|grep -v Hotfix
|grep '"name" :'
|cut -d" -f4
|sed 's/"//g;s/,//g;'
)

Loop through each to compile a listing of existing collections...

do printf "\n%s: \n" "${i}" &&
for j in ( m o n g o l o c a l h o s t : 27017 / {i} --quiet --eval "db.getCollectionNames().join('\n')"
|grep -v Hotfix
|sed 's/^/\t/g;'
)

Loop through these to compile a listing of available fields needed on output...

  do printf "\nCREATE TABLE %s ( \n" ${j} \
     && mongodb-schema localhost:27017 --values=false --format=json ${i}.${j} 2>/dev/null \
        |grep '"path":' \
        |cut -d: -f2 \
        |uniq \
        |sed 's/^/         /g;' \
     && printf "         %s ); \n" " \"X\"" 
  done 

done
`
Thoughts?

Activity

rueckstiess

rueckstiess commented on Aug 4, 2017

@rueckstiess
Contributor

Looks like a problem with the progress module (that renders the progress bar) on Windows. Other projects had similar issues with the same error message. This one seems to indicate that an upgrade to progress@2.x would fix it: expo/create-react-native-app#179

curleb

curleb commented on Aug 4, 2017

@curleb
Author
curleb

curleb commented on Aug 7, 2017

@curleb
Author

Turns out the issue is caused by the handling of the sample and repeat variables. My version of Progress was up to speed as it was, but I appreciate the direction.

Works in Windows, but not under Git Bash. Commented the call out for now since my targets are relatively small; mongodb-schema, ln 178-180. I'll see if I can default dummy values explicitly for all platforms in the near-term, although it looks like the optargs section is a little disheveled. I'm not sure why they're misbehaving under Bash, since they're running on the same machine...and Bash is a sub-shell to cmd.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @rueckstiess@curleb

        Issue actions

          Runs in cmd, but not in Git Bash... · Issue #47 · mongodb-js/mongodb-schema