Comparing version 0.0.12 to 0.0.14
@@ -40,4 +40,4 @@ #!/usr/bin/env node | ||
var file1 = $.mktemp({ dir: tempDir, suffix: '.txt' }); | ||
var file2 = $.mktemp({ dir: tempDir, suffix: '.txt'}); | ||
var file3 = $.mktemp({ dir: tempDir, suffix: '.txt'}); | ||
var file2 = $.mktemp({ dir: tempDir, suffix: '.txt' }); | ||
var file3 = $.mktemp({ dir: tempDir, suffix: '.txt' }); | ||
@@ -47,2 +47,3 @@ $.write(file1, 'one').write(file2, 'two').write(file3, 'three'); | ||
$.cout($.stringify($.walk(tempDir))); | ||
}); |
{ | ||
"name": "main", | ||
"version": "0.0.12", | ||
"version": "0.0.14", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -160,3 +160,6 @@ node-main | ||
``` | ||
##### `$.mkdir(directoryPath)` | ||
Given a path to a directory, it will create it if it doesn't already exist. It will create parent directorys as needed. Works similar to `mkdir -p` on linux systems. | ||
##### `$.read(fileName)` | ||
@@ -203,3 +206,3 @@ | ||
##### `$.assert.argsLen` | ||
#### Arguments | ||
@@ -209,10 +212,10 @@ Check for positional arguments length. There is a family of checks available for use: | ||
- `$.assert.argsLen(length)` positional arguments equals length? | ||
- `$assert.argsLenGe(length)` args greater than or equal to length? | ||
- `$assert.argsLenGt(length)` args greater than length? | ||
- `$assert.argsLenLe(length)` args less than or equal to length? | ||
- `$assert.argsLenLt(length)` args less than length? | ||
- `$.assert.argsLenGe(length)` args greater than or equal to length? | ||
- `$.assert.argsLenGt(length)` args greater than length? | ||
- `$.assert.argsLenLe(length)` args less than or equal to length? | ||
- `$.assert.argsLenLt(length)` args less than length? | ||
##### `$assert.fileExists(fileName)` | ||
#### Files | ||
Checks if a file exists. Useful if you want to ensure a file exists before reading from it, e.g. | ||
- `$assert.fileExists(fileName)` Checks if a file exists. Useful if you want to ensure a file exists before reading from it, e.g. | ||
@@ -219,0 +222,0 @@ ```javascript |
@@ -124,6 +124,20 @@ var extend = require('util')._extend; | ||
/* | ||
Makes a directory, that is it. | ||
Makes a directory. Will create parent directories if they are needed. | ||
*/ | ||
self.mkdir = function(path) { | ||
require('fs').mkdirSync(path); | ||
self.mkdir = function(directoryPath) { | ||
var path = require('path'), fs = require('fs'); | ||
var split = directoryPath.split(path.sep); | ||
// Handle cases where user specifies root, e.g. /home/nolan/... | ||
if (split[0] == '') { | ||
split.shift(); | ||
split[0] = path.sep + split[0]; | ||
} | ||
split.reduce(function(previous, current) { | ||
var newPath = path.join(previous, current); | ||
fs.existsSync(newPath) || fs.mkdirSync(newPath); | ||
return newPath; | ||
}); | ||
return self; | ||
@@ -130,0 +144,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20719
328
273