创建目录(树)phantomjs casperjs无法正常工作

时间:2017-02-01 10:09:44

标签: directory phantomjs casperjs

我正在使用Windows 10 X64

使用casperjs和phantomjs

使用phantomjs 2.1.1版的C:/ casperjs的CasperJS 1.1.2版本

尝试使用它创建多个目录,但没有运气,唯一的工作是仅创建1个目录

来自文件

http://phantomjs.org/api/fs/method/make-tree.html

D:\work>casperjs dir.js
"D:\test\1\1\2" is NOT created.

D:\work>casperjs dir.js
"D:\test2" was created.  // this work when make 1 dir only

D:\work>casperjs dir.js
"D:\test3\2dd" is NOT created.

D:\work>casperjs dir.js
"D:\test2\2ss" was created. . // Working because test2 was created before

D:\work>casperjs dir.js
"D:\test2\2ss\hhh\gu" is NOT created.

结果(路径已更改)

$filtered = array_filter(
    $myarray,
    function (array $item) {
        return array_key_exists('show_nav', $item) && $item['show_nav'] === 'yes';
    }
);

1 个答案:

答案 0 :(得分:0)

将makedirectory更改为maketree。 它会起作用!

var fs = require('fs');
var path = 'D:\\test2\\2ss\\hhh\\gu';
if(fs.makeTree(path))
console.log('"'+path+'" was created.');
else
console.log('"'+path+'" is NOT created.');
phantom.exit();

结果

D:\work>casperjs dir.js
"D:\test2\2ss\hhh\gu" was created.