让phantomjs运行当前目录中所有“的* .js”文件 [英] Make phantomjs run all '*.js' files in the current directory

查看:181
本文介绍了让phantomjs运行当前目录中所有“的* .js”文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个脚本调用 phantomjs 在一个目录一堆测试脚本。
这个脚本运行的第一个测试,然后退出。

I want to write a script to call phantomjs on a bunch of test scripts in a directory. This script runs the first test and then exits.

#!/bin/bash

find . -maxdepth 1 -name '*.js' -type f -exec phantomjs {} +

执行与类似的命令回声,像

find . -maxdepth 1 -name '*.js' -type f -exec echo {} +

印刷品(如预期)中的所有文件名中的目录。

prints (as expected) all the filenames in the directory.

我怎样才能让phantomjs运行在当前目录下的所有的.js 文件?这是一个bash的问题还是phantomjs问题?

How can I make phantomjs run all .js files in the current directory? Is this a bash problem or a phantomjs problem?

推荐答案

据我所知phantomjs将只支持当时的一个文件。你需要告诉找到来调用每个找到的文件phantomjs:

AFAIK phantomjs will only support one file at the time. You need to tell find to call phantomjs for each found file:

#!/bin/sh
find . -maxdepth 1 -name '*.js' -type f -exec phantomjs {} ';'

您也可以使用:

#!/bin/sh
for file in *.js; do
  [ -f "$file" ] || continue
  phantomjs "$file"
done

这篇关于让phantomjs运行当前目录中所有“的* .js”文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆