summaryrefslogtreecommitdiffstats
path: root/packages/gitbook/lib/json/encodeFile.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-09-05 11:04:18 +0200
committerSamy Pessé <samypesse@gmail.com>2016-09-05 11:04:18 +0200
commita14ca3e268e95a7eab59fb205b41da7331d57631 (patch)
tree9c84b2cbd561345335fca3e26af961b2ea23d8ec /packages/gitbook/lib/json/encodeFile.js
parent9c071dade573aa6990878006f83c89b6065a1395 (diff)
downloadgitbook-a14ca3e268e95a7eab59fb205b41da7331d57631.zip
gitbook-a14ca3e268e95a7eab59fb205b41da7331d57631.tar.gz
gitbook-a14ca3e268e95a7eab59fb205b41da7331d57631.tar.bz2
Switch to lerna
Diffstat (limited to 'packages/gitbook/lib/json/encodeFile.js')
-rw-r--r--packages/gitbook/lib/json/encodeFile.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/gitbook/lib/json/encodeFile.js b/packages/gitbook/lib/json/encodeFile.js
new file mode 100644
index 0000000..d2c9e8a
--- /dev/null
+++ b/packages/gitbook/lib/json/encodeFile.js
@@ -0,0 +1,21 @@
+
+/**
+ Return a JSON representation of a file
+
+ @param {File} file
+ @return {Object}
+*/
+function encodeFileToJson(file) {
+ var filePath = file.getPath();
+ if (!filePath) {
+ return undefined;
+ }
+
+ return {
+ path: filePath,
+ mtime: file.getMTime(),
+ type: file.getType()
+ };
+}
+
+module.exports = encodeFileToJson;