创建目录(树)phantomjs casperjs 不工作
create directory (tree) phantomjs casperjs not working
我正在研究 windows 10 X64
使用 casperjs 和 phantomjs
CasperJS 版本 1.1.2 在 C:/casperjs,使用 phantomjs 版本 2.1.1
尝试用它创建多目录但没有成功,唯一的工作是只创建 1 个目录
来自文档
http://phantomjs.org/api/fs/method/make-tree.html
var fs = require('fs');
var path = 'D:\test2\2ss\hhh\gu';
if(fs.makeDirectory(path))
console.log('"'+path+'" was created.');
else
console.log('"'+path+'" is NOT created.');
phantom.exit();
结果(路径已更改)
D:\work>casperjs dir.js
"D:\test" 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:\test3dd" is NOT created.
D:\work>casperjs dir.js
"D:\test2ss" was created. . // Working because test2 was created before
D:\work>casperjs dir.js
"D:\test2ss\hhh\gu" is NOT created.
将 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:\test2ss\hhh\gu" was created.
我正在研究 windows 10 X64
使用 casperjs 和 phantomjs
CasperJS 版本 1.1.2 在 C:/casperjs,使用 phantomjs 版本 2.1.1
尝试用它创建多目录但没有成功,唯一的工作是只创建 1 个目录
来自文档
http://phantomjs.org/api/fs/method/make-tree.html
var fs = require('fs');
var path = 'D:\test2\2ss\hhh\gu';
if(fs.makeDirectory(path))
console.log('"'+path+'" was created.');
else
console.log('"'+path+'" is NOT created.');
phantom.exit();
结果(路径已更改)
D:\work>casperjs dir.js
"D:\test" 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:\test3dd" is NOT created.
D:\work>casperjs dir.js
"D:\test2ss" was created. . // Working because test2 was created before
D:\work>casperjs dir.js
"D:\test2ss\hhh\gu" is NOT created.
将 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:\test2ss\hhh\gu" was created.