# forcepaths

> Create folders and files even if parent folders don't exist

Latest version **1.0.5** (published 2014-07-05) · 0 weekly downloads

## Install

```sh
npm install forcepaths
pnpm add forcepaths
yarn add forcepaths
bun add forcepaths
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2014-07-05 |
| First published | 2014-07-01 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jonathan Annett |
| Maintainers | sophtwhere |

## Links

- npm: https://www.npmjs.com/package/forcepaths
- Repository: https://github.com/sophtwhere/forcepaths
- npm.io page: https://npm.io/package/forcepaths

## Dependencies (2)

- [eachkv](https://npm.io/package/eachkv.md) >=1.0.7
- [requireasync](https://npm.io/package/requireasync.md) >=0.0.9

## Recent versions

- 1.0.5 (latest) — 2014-07-05
- 1.0.4 — 2014-07-03
- 1.0.3 — 2014-07-01
- 1.0.2 — 2014-07-01
- 1.0.1 — 2014-07-01

## README

forcepaths
==========

Create folders and files even if parent folders don't exist (node js)

**Create a folder**

    var forcePaths = require('forcePaths');
    
    forcePaths(
        "./my/long/path/to/a/folder",
        function(err,stat){
            if (!err) {
			     if (stat.isDirectory()) {
					// this test is only needed if you
					// want to verify that the path was not 
					// previously a file.
			     }
    		  }
        }
    );
    



**Create a file**

    var forcePaths = require('forcePaths');
    
    forcePaths(
        "./my/long/path/to/a/file/hello.txt",
        "hello world",// <<< write this text to the file
        function(err,stat){
           if (err) {
              console.log(err);
           } 
        }
    );
    
    
    
**$R$ syntax (from requireasync)**

    eval(require('requireasync').install)

	$R$({forcepaths:0})("./my/path/to/afile.txt","write this there");


**Power user syntax**

    eval(require('requireasync').install)
    
	$R$({

		forcepaths:function(f){

			f("./my/path/to/afile.txt","write this there");
			f("./my/path/to/folder");
			f("./my/path/to/anotherfile","write this there");
			f("./my/path/to/folder/subfolder",function(err,stat){ console.log(err?err:stat?stat.mtime:"wtf happened?");});

		}

	})

---
_Source: https://npm.io/package/forcepaths · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
