简体   繁体   English

如何从现有的 npm 模块 (codius) 开发 javascript 库

[英]How to develop a javascript library from an already existing npm module (codius)

never done this before.从来没有这样做过。

I'm using https://github.com/codius/codius-host .我正在使用https://github.com/codius/codius-host Codiu§ development has been abandoned, but I want to salvage part of it to use for my own project. Codiu§ 开发已被放弃,但我想挽救一部分用于我自己的项目。 I really need to be able to run codius commands from browser, so I need to develop a library or what you call it.我真的需要能够从浏览器运行 codius 命令,所以我需要开发一个库或你所说的。

var codius = require('codius')

codius.upload({host: http://contract.host}

codius-host comes packed with command-line integration, codius-host 带有命令行集成,

$ CODIUS_HOST=https://codius.host codius upload

How do I make a .js script do what the command-line command does ?如何让 .js 脚本执行命令行命令的操作?

also posted on https://stackoverflow.com/questions/31126511/if-i-have-a-npm-tool-that-uses-comman-line-commands-how-can-i-create-a-javascri hard time asking this questions since don't know where to start.也发布在https://stackoverflow.com/questions/31126511/if-i-have-a-npm-tool-that-uses-comman-line-commands-how-can-i-create-a-javascri困难时期问这个问题,因为不知道从哪里开始。 help.帮助。

Assuming that you have access to the codius-host source code you should find the piece of code which manages the command line arguments.假设您可以访问 codius-host 源代码,您应该找到管理命令行参数的代码段。 I am sure that they do handle the command and the command line arguments from an entry module/function and than later delegate the real job to a different module/function.我确信他们确实处理来自入口模块/函数的命令和命令行参数,然后将真正的工作委托给不同的模块/函数。 What you need to do is to provide correct parameters to the functions which the function/module that handles command line argument calls with command line parameters.您需要做的是为处理命令行参数的函数/模块使用命令行参数调用的函数提供正确的参数。

In addition to that there are some nodejs libraries that might imitate a command line call from the program itself.除此之外,还有一些 nodejs 库可能会模仿程序本身的命令行调用。 One of those I know is shelljs:我所知道的其中之一是 shelljs:

https://www.npmjs.com/package/shelljs https://www.npmjs.com/package/shelljs

You might want to check this out as well.您可能也想检查一下。 With this one without bothering with the source code you might be able to imitate command line behaviour.有了这个而无需打扰源代码,您可能能够模仿命令行行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM