UNPKG

5.5 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+ [.mkdir(dirname)](#method-mkdir)
155+ [.mkdirAll(dirnames)](#method-mkdir-all)
156+ [.chmod(pattern, permission)](#method-chmod)
157+ [.chmodAll(permissions)](#method-chmod-all)
158
159<a name="method-ping"></a>
160### .ping(pong)
161
162Test the reachability of the api
163
164| Param | Type | Description |
165| ----- | ---- | ----------- |
166| pong | <code>string</code> | Pong message to return |
167
168<a name="method-glob"></a>
169### .glob(pattern)
170
171Resolve glob file name pattern
172
173| Param | Type | Description |
174| ----- | ---- | ----------- |
175| pattern | <code>string</code> | Glob file name pattern |
176
177<a name="method-mkdir"></a>
178### .mkdir(dirname)
179
180Generate a directory
181
182| Param | Type | Description |
183| ----- | ---- | ----------- |
184| dirname | <code>string</code> | Directory name to generate |
185
186<a name="method-mkdir-all"></a>
187### .mkdirAll(dirnames)
188
189Generate multiple directories
190
191| Param | Type | Description |
192| ----- | ---- | ----------- |
193| dirnames | <code>array</code> | Directory names to generate |
194
195<a name="method-chmod"></a>
196### .chmod(pattern, permission)
197
198Change file permissions
199
200| Param | Type | Description |
201| ----- | ---- | ----------- |
202| pattern | <code>string</code> | Glob filename pattern |
203| permission | <code>string</code> | Permission string (like "644") |
204
205<a name="method-chmod-all"></a>
206### .chmodAll(permissions)
207
208Change file permissions
209
210| Param | Type | Description |
211| ----- | ---- | ----------- |
212| permissions | <code>array</code> | Pattern and permissions |
213
214
215
216<!-- Section from "doc/guides/03.Methods.md.hbs" End -->
217
218
219<!-- Sections Start -->
220
221
222<!-- LICENSE Start -->
223<a name="license"></a>
224
225License
226-------
227This software is released under the [MIT License](https://github.com/apeman-api-labo/apeman-api-fs/blob/master/LICENSE).
228
229<!-- LICENSE End -->
230
231
232<!-- Links Start -->
233<a name="links"></a>
234
235Links
236------
237
238+ [apeman][apeman_url]
239
240[apeman_url]: https://github.com/apeman-labo/apeman
241
242<!-- Links End -->