Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robojones/mystuff
https://github.com/robojones/mystuff
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/robojones/mystuff
- Owner: robojones
- License: gpl-3.0
- Created: 2016-08-18T10:08:43.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-12T12:36:21.000Z (about 8 years ago)
- Last Synced: 2024-02-17T07:02:26.053Z (9 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mystuff - easier local require
This module makes it easier to organize and require your local modules.
It also gives you the ability to set global variables that you can use in all of your projects.
## Installation
`npm install mystuff`When you require `mystuff` for the first time it creates a folder named `own_modules` in your users home directory.
In this folder you can store your own modules.
## Own Modules
You can create your modules in two ways: as a single JavaScript file or as a directory.
### File
1. Create a JavaScript file e.g. `example.js` in the `own_modules` folder.
2. Write your Code in the file and set the `module.exports` property.
3. Now you can require this file in all of your projects.
```
const mystuff = require('mystuff');
var example = mystuff('example');
//or
var example = mystuff('example.js');
```
### Directory
1. Create a directory e.g. `anotherExample` in the `own_modules` folder.
2. Add a JavaScript file called `anotherExample.js` or `main.js` in the new directory. They are used as entry-point.
3. Write your code in the JavaScript file and set the `module.exports` property.
4. Now you can require this module in all of your projects.
```
const mystuff = require('mystuff');
const anotherExample = mystuff('anotherExample');
```
__Tip:__ The `main.js` file ist the prefered entry-point.### cd(path)
Change the directory where your `own_modules` folder is located in.
The change affects the whole node app.