{"action":"closed","issue":{"url":"https://api.github.com/repos/marksherman/snapshot-service/issues/5","labels_url":"https://api.github.com/repos/marksherman/snapshot-service/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/marksherman/snapshot-service/issues/5/comments","events_url":"https://api.github.com/repos/marksherman/snapshot-service/issues/5/events","html_url":"https://github.com/marksherman/snapshot-service/issues/5","id":108202835,"number":5,"title":"Creating System Call library module","user":{"login":"marksherman","id":2035149,"avatar_url":"https://avatars.githubusercontent.com/u/2035149?v=3","gravatar_id":"","url":"https://api.github.com/users/marksherman","html_url":"https://github.com/marksherman","followers_url":"https://api.github.com/users/marksherman/followers","following_url":"https://api.github.com/users/marksherman/following{/other_user}","gists_url":"https://api.github.com/users/marksherman/gists{/gist_id}","starred_url":"https://api.github.com/users/marksherman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marksherman/subscriptions","organizations_url":"https://api.github.com/users/marksherman/orgs","repos_url":"https://api.github.com/users/marksherman/repos","events_url":"https://api.github.com/users/marksherman/events{/privacy}","received_events_url":"https://api.github.com/users/marksherman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-24T20:01:25Z","updated_at":"2015-09-28T19:01:11Z","closed_at":"2015-09-28T19:01:11Z","body":"I'm currently porting the saveProgram function from this file to work with our data: https://github.com/derrell/LearnCS/blob/master/dbif/source/class/playground/dbif/MFiles.js\r\n\r\nproblem is, that project used a custom platform that @derrell wrote (for his masters, actually), called LIBERATED. I am *not* using that platform, so there are a few features he's calling that are wrapped up that I don't have.\r\n\r\nAfter looking at available modules and how to do it raw in node.js, it looks like the easiest way is to write the system calls that we need ourselves, as a separate file/module specific to this project. basically, build a library to talk to the underlying system.\r\n\r\nHere is the LIBERATED system library: https://github.com/liberated/liberated/blob/master/source/class/liberated/node/System.js\r\n\r\n### Functions that are needed:\r\n\r\n```System.system( [ \"mkdir\", \"-p\", gitDir ])```\r\n**System.system** - to run the git commands (or any other commands) - wrapper for a synchronous child call in node.js\r\nhttps://nodejs.org/api/child_process.html#child_process_synchronous_process_creation\r\nMust also capture return codes, as is used in the MFiles.js:saveProgram\r\n\r\nNote: Derrell's included a second argument, a parameter object, in which he can specify ```{ showStdout : true }```, but I think we can include default behavior and not have to specify anything like that. It is possible we may learn the reason why he included that by doing.\r\n\r\n```System.writeFile( \"blocks.xml\", blocks, { encoding : \"utf8\" })```\r\n**System.writeFile** - write file to disk. Uses the node fs API: https://nodejs.org/api/fs.html\r\nThis also has the parameter object, which I'm still not sure we need. Specifying utf8 hard-coded in our one-purpose library sounds fine to me.\r\n\r\nThere are more advanced features that Derrell had written, which will rely on a few more System functions, which we can do later.\r\nSo, I'll call them...\r\n\r\n### Functions that May Be Needed Soon But Not Quite Right Now:\r\n\r\n**System.readdir** - read contents of a directory, also based on fs API\r\n**System.readFile** - read a specific file, also based on fs API\r\n**System.rename** - etc\r\n**System.fileExists** - etc\r\n\r\n### Instructions\r\nImplement these tools as a file in the server directory of snapshot-service, providing library functions using node's module exports mechanism. \r\n\r\nProvide this new file as a pull request. "}}