apeman-api-path

File path API for apeman


Keywords
apeman, api
License
MIT
Install
npm install apeman-api-path@1.1.4

Documentation

apeman-api-path

Build Status Code Climate Code Coverage npm Version JS Standard

File path API for apeman

Installation

$ npm install apeman-api-path --save

Usage

Define a module in Apemanfile and run the server.

/** Example of Apemanfile.js */

'use strict'

const co = require('co')

let { NODE_ENV } = process.env

module.exports = {
  $cwd: __dirname,
  $pkg: { /* ... */ },
  $proto: [ /* ... */ ],
  $api: {
    // Define APIs
    'path': require('apeman-api-path')({
      logging: NODE_ENV === 'development',
      root: {

      }
    })
  }
}

Then, call the module from client script

#!/usr/bin/env node

/**
 * Example client
 */
'use strict'

const co = require('co')
const apemanApiClient = require('apeman-api-client')

co(function * () {
  // Setup an client
  let api = yield apemanApiClient('/api')

  // Connect to a module
  let path = yield api.connect('path')
  {
    let resolved = yield path.resolve('foo/bar', '../baz')
    console.log(resolved) // => foo/bar/baz
  }
  /* ... */
})

Methods

The following methods are provided by the API.

.ping(pong)

Test the reachability of the api.

Param Type Description
pong string Pong message to return

.dirname(filename)

Resolve directory name

Param Type Description
filename string Filename to resolve

.basename(filename, extname)

Get base name

Param Type Description
filename string Filename to resolve
extname string Extension name to strip off.

.relative(from, to)

Resolve relative path

Param Type Description
from string Relative filename from
to string Relative filename to

.absolute(pathnames)

Resolve to absolute path

Param Type Description
pathnames ...string

.resolve(filenames)

Resolve a file path

Param Type Description
filenames ...string Filenames to resolve

License

This software is released under the MIT License.

Links