UNPKG

5.95 kBMarkdownView Raw
1apeman-api-fs
2==========
3
4<!---
5This file is generated by ape-tmpl. Do not update manually.
6--->
7
8<!-- Badge Start -->
9<a name="badges"></a>
10
11[![Build Status][bd_travis_shield_url]][bd_travis_url]
12[![Code Climate][bd_codeclimate_shield_url]][bd_codeclimate_url]
13[![Code Coverage][bd_codeclimate_coverage_shield_url]][bd_codeclimate_url]
14[![npm Version][bd_npm_shield_url]][bd_npm_url]
15[![JS Standard][bd_standard_shield_url]][bd_standard_url]
16
17[bd_repo_url]: https://github.com/apeman-api-labo/apeman-api-fs
18[bd_travis_url]: http://travis-ci.org/apeman-api-labo/apeman-api-fs
19[bd_travis_shield_url]: http://img.shields.io/travis/apeman-api-labo/apeman-api-fs.svg?style=flat
20[bd_travis_com_url]: http://travis-ci.com/apeman-api-labo/apeman-api-fs
21[bd_travis_com_shield_url]: https://api.travis-ci.com/apeman-api-labo/apeman-api-fs.svg?token=
22[bd_license_url]: https://github.com/apeman-api-labo/apeman-api-fs/blob/master/LICENSE
23[bd_codeclimate_url]: http://codeclimate.com/github/apeman-api-labo/apeman-api-fs
24[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/apeman-api-labo/apeman-api-fs.svg?style=flat
25[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/apeman-api-labo/apeman-api-fs.svg?style=flat
26[bd_gemnasium_url]: https://gemnasium.com/apeman-api-labo/apeman-api-fs
27[bd_gemnasium_shield_url]: https://gemnasium.com/apeman-api-labo/apeman-api-fs.svg
28[bd_npm_url]: http://www.npmjs.org/package/apeman-api-fs
29[bd_npm_shield_url]: http://img.shields.io/npm/v/apeman-api-fs.svg?style=flat
30[bd_standard_url]: http://standardjs.com/
31[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
32
33<!-- Badge End -->
34
35
36<!-- Description Start -->
37<a name="description"></a>
38
39File system API for apeman
40
41<!-- Description End -->
42
43
44<!-- Overview Start -->
45<a name="overview"></a>
46
47
48
49<!-- Overview End -->
50
51
52<!-- Sections Start -->
53<a name="sections"></a>
54
55<!-- Section from "doc/guides/01.Installation.md.hbs" Start -->
56
57<a name="section-doc-guides-01-installation-md"></a>
58
59Installation
60-----
61
62```bash
63$ npm install apeman-api-fs --save
64```
65
66
67<!-- Section from "doc/guides/01.Installation.md.hbs" End -->
68
69<!-- Section from "doc/guides/02.Usage.md.hbs" Start -->
70
71<a name="section-doc-guides-02-usage-md"></a>
72
73Usage
74---------
75
76Define a module in Apemanfile and run the server.
77
78```javascript
79/** Example of Apemanfile.js */
80
81'use strict'
82
83const co = require('co')
84
85let { NODE_ENV } = process.env
86
87module.exports = {
88 $cwd: __dirname,
89 $pkg: { /* ... */ },
90 $proto: [ /* ... */ ],
91 $api: {
92 // Define APIs
93 'fs': require('apeman-api-fs')({
94 root: __dirname,
95 logging: NODE_ENV === 'development'
96 })
97 }
98}
99
100```
101
102Then, call the module from client script
103
104```javascript
105#!/usr/bin/env node
106
107/**
108 * Example client
109 */
110'use strict'
111
112const co = require('co')
113const apemanApiClient = require('apeman-api-client')
114
115co(function * () {
116 // Setup an client
117 let api = yield apemanApiClient('/api')
118
119 // Connect to a module
120 let fs = yield api.connect('fs')
121 let pong = yield fs.ping()
122 /* ... */
123
124 yield fs.mkdirAll([
125 'bin',
126 'lib',
127 'lib/config',
128 'test'
129 ])
130
131 yield fs.chmod('bin/*.js', '755')
132
133 yield fs.chmodAll({ 'ci/*.js': '755' })
134 /* ... */
135})
136
137
138```
139
140
141<!-- Section from "doc/guides/02.Usage.md.hbs" End -->
142
143<!-- Section from "doc/guides/03.Methods.md.hbs" Start -->
144
145<a name="section-doc-guides-03-methods-md"></a>
146
147Methods
148---------
149
150The following methods are provided by the API.
151
152+ [.ping(pong)](#method-ping)
153+ [.glob(pattern)](#method-glob)
154+ [.exists(filename)](#method-exists)
155+ [.stat(filename)](#method-stat)
156+ [.mkdir(dirname)](#method-mkdir)
157+ [.mkdirAll(dirnames)](#method-mkdir-all)
158+ [.chmod(pattern, permission)](#method-chmod)
159+ [.chmodAll(permissions)](#method-chmod-all)
160
161<a name="method-ping"></a>
162### .ping(pong)
163
164Test the reachability of the api
165
166| Param | Type | Description |
167| ----- | ---- | ----------- |
168| pong | <code>string</code> | Pong message to return |
169
170<a name="method-glob"></a>
171### .glob(pattern)
172
173Resolve glob file name pattern
174
175| Param | Type | Description |
176| ----- | ---- | ----------- |
177| pattern | <code>string</code> | Glob file name pattern |
178
179<a name="method-exists"></a>
180### .exists(filename)
181
182File exists or not
183
184| Param | Type | Description |
185| ----- | ---- | ----------- |
186| filename | <code>string</code> | File name |
187
188<a name="method-stat"></a>
189### .stat(filename)
190
191Get stat of a file
192
193| Param | Type | Description |
194| ----- | ---- | ----------- |
195| filename | <code>string</code> | File name to get stat |
196
197<a name="method-mkdir"></a>
198### .mkdir(dirname)
199
200Generate a directory
201
202| Param | Type | Description |
203| ----- | ---- | ----------- |
204| dirname | <code>string</code> | Directory name to generate |
205
206<a name="method-mkdir-all"></a>
207### .mkdirAll(dirnames)
208
209Generate multiple directories
210
211| Param | Type | Description |
212| ----- | ---- | ----------- |
213| dirnames | <code>array</code> | Directory names to generate |
214
215<a name="method-chmod"></a>
216### .chmod(pattern, permission)
217
218Change file permissions
219
220| Param | Type | Description |
221| ----- | ---- | ----------- |
222| pattern | <code>string</code> | Glob filename pattern |
223| permission | <code>string</code> | Permission string (like "644") |
224
225<a name="method-chmod-all"></a>
226### .chmodAll(permissions)
227
228Change file permissions
229
230| Param | Type | Description |
231| ----- | ---- | ----------- |
232| permissions | <code>array</code> | Pattern and permissions |
233
234
235
236<!-- Section from "doc/guides/03.Methods.md.hbs" End -->
237
238
239<!-- Sections Start -->
240
241
242<!-- LICENSE Start -->
243<a name="license"></a>
244
245License
246-------
247This software is released under the [MIT License](https://github.com/apeman-api-labo/apeman-api-fs/blob/master/LICENSE).
248
249<!-- LICENSE End -->
250
251
252<!-- Links Start -->
253<a name="links"></a>
254
255Links
256------
257
258+ [apeman][apeman_url]
259
260[apeman_url]: https://github.com/apeman-labo/apeman
261
262<!-- Links End -->