shelljs

https://github.com/shelljs/shelljs

实例

var shell = require('shelljs');

if (!shell.which('git')) {
shell.echo('Sorry, this script requires git');
shell.exit(1);
} // Copy files to release dir
shell.rm('-rf', 'out/Release');
shell.cp('-R', 'stuff/', 'out/Release'); // Replace macros in each .js file
shell.cd('lib');
shell.ls('*.js').forEach(function (file) {
shell.sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
shell.sed('-i', /^.*REMOVE_THIS_LINE.*$/, '', file);
shell.sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, shell.cat('macro.js'), file);
});
shell.cd('..'); // Run external tool synchronously
if (shell.exec('git commit -am "Auto-commit"').code !== 0) {
shell.echo('Error: Git commit failed');
shell.exit(1);
} var version = exec('node --version', {silent:true}).stdout; var child = exec('some_long_running_process', {async:true});
child.stdout.on('data', function(data) {
/* ... do something with data ... */
}); exec('some_long_running_process', function(code, stdout, stderr) {
console.log('Exit code:', code);
console.log('Program output:', stdout);
console.log('Program stderr:', stderr);
});

nodejs调用shell的更多相关文章

  1. perl 调用shell脚本

    perl调用shell命令 perl调用shell shell调用perl Perl执行shell命令的几种方式及其区别

  2. 【原】Gradle调用shell脚本和python脚本并传参

    最近由于项目自动化构建的需要,研究了下gradle调用脚本并传参的用法,在此作个总结. Pre build.gradle中定义了$jenkinsJobName $jenkinsBuild两个Jenki ...

  3. 调用shell脚本,IP处理

    //调用shell脚本,IP处理 package com.letv.sdns.web.utils; import org.slf4j.Logger; import org.slf4j.LoggerFa ...

  4. python 调用 shell 命令方法

    python调用shell命令方法 1.os.system(cmd) 缺点:不能获取返回值 2.os.popen(cmd) 要得到命令的输出内容,只需再调用下read()或readlines()等   ...

  5. Awk中调用shell命令

    Awk中调用shell命令 需求 在awk中,有时候需要调用linux系统中命令,如计算字符串的MD5值,并保存下来. 方法参考 call a shell command from inside aw ...

  6. C程序调用shell脚本共有三种方法

    C程序调用shell脚本共有三种法子 :system().popen().exec系列函数call_exec1.c ,内容为:system() 不用你自己去产生进程,它已经封装了,直接加入自己的命令e ...

  7. 【转载】如何在C语言中调用shell命令

    转载自:http://blog.csdn.net/chdhust/article/details/7951576 如何在C语言中调用shell命令 在linux操作系统中,很多shell命令使用起来非 ...

  8. AWK调用SHELL,并将变量传递给SHELL

    在Shell脚本中调用awk是非常自然和简单的,以前还写过一个关于awk/shell相互传递变量的文章:awk与shell之间的变量传递方法在awk脚本中,如果需要调用shell脚本/命令,则需要使用 ...

  9. [转] Makefile中调用Shell

    1.在Makefile中只能在target中调用Shell脚本,其他地方是不能输出的.比如如下代码就是没有任何输出: VAR="Hello" echo "$(VAR)&q ...

  10. python调用shell, shell 引用python

    python 调用 shell get_line_num="wc -l as_uniq_info | awk '{print $1}'" ###get the lines of & ...

随机推荐

  1. 第一章 Java集合框架

    ----------------------------------------------------------------------------- Java集合框架(一)-ArrayList ...

  2. ClustrixDB-new数据库

    ClustrixDB是一种集群式RDBMS,可确保事务处理符合ACID特性,同时可轻松的提供可扩展性和容错能力. ClustrixDB集群由三个或更多节点(联网的同构服务器)组成.ClustrixDB ...

  3. w3cschool-Linux 教程

    https://www.w3cschool.cn/linux/ Linux 安装 本章节我们将为大家介绍 Linux 的安装,安装步骤比较繁琐,现在其实云服务器挺普遍的,价格也便宜,如果自己不想搭建, ...

  4. uniapp去修改vuex中state中的值

    修改state中的值 修改state中的值,方法 (1) 在mutations中写修改state的api. (2)写好之后,直接store.commit("changeValue" ...

  5. sql中的inerval函数使用方法

    在SQL中,INTERVAL函数可以用于添加或减去特定的时间间隔.其基本语法如下: SELECT field1, field2, ... FROM table_name WHERE condition ...

  6. 使用必读-使用Iceberg数据湖需要注意的点

    一.开发注意事项 1.Iceberg选择合适的表版本 简述:Iceberg目前有两个表版本(V1和V2),根据数据选择合适的表版本. V1表只支持增量数据插入,适合做纯增量写入场景,如埋点数据. V2 ...

  7. Flink中的时间分类

    一.分类 1.1 事件时间:EventTime 事件发⽣的时间 事件时间是每个单独事件在其产⽣进程上发⽣的时间,这个时间通常在处理的消息体中,如创建时间 在事件时间中,时间值 取决于数据产⽣记录的时间 ...

  8. FreeSql学习笔记——0.FreeSql启动!

    FreeSql FreeSql是功能强大的 .NET ORM,支持 .NetFramework 4.0+..NetCore 2.1+.Xamarin等支持 NetStandard 所有运行平台.支持  ...

  9. 天线驻波比&回波损耗

    天线驻波比(VSWR)‌,全称为电压驻波比,是衡量天线系统匹配程度的重要参数.它定义为驻波波腹处的电压幅值与波谷处的电压幅值之比.理想情况下,当馈线和天线的阻抗完全匹配时,驻波比为1,表示高频能量全部 ...

  10. Golang 实现本地持久化缓存

    // Copyright (c) 2024 LiuShuKu // Project Name : balance // Author : liushuku@yeah.net package cache ...