diff --git a/README.md b/README.md
index 4f2c187..504588c 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,7 @@ Completed PHP Method
* parse_str : parse "a=b&c=d" to {"a": "b", "c": "d"}
* array_merge
* clone: clone a object or array
+* getcwd
Install phplike
diff --git a/nodejs/core.js b/nodejs/core.js
index 65b9949..7815a27 100644
--- a/nodejs/core.js
+++ b/nodejs/core.js
@@ -68,6 +68,11 @@ exports.date = function (format)
return format;
}/*}}}*/
+// Get current working directory (path).
+exports.getcwd = function () {//{{{
+ return process.cwd();
+}//}}}
+
/*
* @param obj
* @param prefix space
diff --git a/nodejs/file.js b/nodejs/file.js
index 452188f..0dc946a 100644
--- a/nodejs/file.js
+++ b/nodejs/file.js
@@ -98,7 +98,7 @@ exports.mkdir = function(dirName) {/*{{{*/
try{
fs.mkdirSync(dir);
} catch(e) {
- print_r(e);
+ console.log(e);
throw e
}
}
diff --git a/tests/core.js b/tests/core.js
index 26af87f..7338241 100644
--- a/tests/core.js
+++ b/tests/core.js
@@ -100,4 +100,11 @@ describe('Test function: clone', function() {
});
+describe('Test function: getcwd', function() {
+ it('string to object', function() {
+ var res = phplikeMod.getcwd();
+ assert.equal("/", res.substring(0, 1));
+ })
+
+});
diff --git a/tests/file.js b/tests/file.js
index c563074..8823dbb 100644
--- a/tests/file.js
+++ b/tests/file.js
@@ -92,6 +92,24 @@ describe('dir handle', function () {
phplikeMod.rmdir("test_dir");
});
+ it('create dir from "/"', function () {
+ var cwd = phplikeMod.getcwd();
+ phplikeMod.mkdir(cwd + "/test_dir");
+ var isDir = phplikeMod.is_dir(cwd + "/test_dir");
+ assert.equal(true, isDir);
+ phplikeMod.rmdir(cwd + "/test_dir");
+ });
+
+ it('get exception when create dir in no permission path.', function () {
+ try {
+ phplikeMod.mkdir("/admin");
+ assert.equal(false, true);
+ } catch (e) {
+ assert.equal(true, true);
+ }
+ });
+
+
it('delete dir - force', function() {
var isForce = true;
phplikeMod.mkdir(dir);