npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fullpath

v1.2.2

Published

A node module to get full path of a directory and your nested directories or the full path of each file at each nested directory.

Downloads

49

Readme

#English version

fullpath

A node module to get full path of a directory and your nested directories or the full path of each file at each nested directory.

release notes:

  • fullpath now has support to exclude folders and select only files with a extension that you specified. Please see examples 4 and 5 for more information about that how to use the new features.

Build Status NPM Downloads

Coverage 99.02%

Installation

$ [sudo] npm install fullpath --save

How to use

The following example attaches fullpath to a simple node.js app

Directory structure:


├── example/
│   ├── empty /
│   ├── nested /
│   │   ├── nested-a/
│   │   │   ├── a1/
│   │   │   │   ├── empty.js
│   │   │   ├── a2/
│   │   │   │   ├── a21/
│   │   │   │   │   ├── a211/
│   │   │   │   │   │   ├── empty.js
│   │   │   │   │   │   ├── example.js
│   │   ├── nested-b/
│   │   │   ├── b1/
│   │   │   │   ├── b11/
│   │   │   │   │   ├── empty.js
│   │   │   │   │   ├── empty.json
│   │   │   │   ├── empty.js
├── index.js

Example 1 - Full path of directories

index.js

const fullPaths = new FullPath.Search({
    'path': '/example',
    'dirname': __dirname,
    'type': 'both', //optional. If you specified this value, by default is set with 'files'
    'allFiles': true //optional. If you specified this value, by default is set with false and the result was full path of files with .js and .json extension.
});

console.log(fullPaths);

Run the app:

node index.js

gives the following output

[ 'your_current_working_directory/example/empty',
  'your_current_working_directory/example/nested',
  'your_current_working_directory/example/nested/nested-a',
  'your_current_working_directory/example/nested/nested-b',
  'your_current_working_directory/example/nested/nested-a/a1',
  'your_current_working_directory/example/nested/nested-a/a2',
  'your_current_working_directory/example/nested/nested-b/b1',
  'your_current_working_directory/example/nested/nested-a/a2/a21',
  'your_current_working_directory/example/nested/nested-b/b1/b11',
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211' ]

Example 2 - Full path of files with any extension

index.js


const fullPaths = new FullPath.Search({
    'path': '/example',
    'dirname': __dirname,
    'type': 'files', //optional. If you don't specified this value, by default is set with 'files'
    'allFiles': true //optional. If you don't specified this value, by default is set with false and the result was full path of files with .js and .json extension.
});

console.log(fullPaths);

Run the app:

node index.js

gives the following output

[ 'your_current_working_directory/example/nested/nested-a/a1/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.json',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.md', // .md
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211/empty.js',
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211/example.js' ]

Example 3 - Full path of files with .json and .js extension.

index.js

const fullPaths = new FullPath.Search({
    'path': '/example',
    'dirname': __dirname,
    'type': 'files', //optional. If you don't specified this value, by default is set with 'files'
    'allFiles': false //optional. If you don't specified this value, by default is set with false and the result was full path of files with .js and .json extension.
});

Run the app:

node index.js

gives the following output

[ 'your_current_working_directory/example/nested/nested-a/a1/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.json',
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211/empty.js',
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211/example.js' ]

Example 4 - Full path of files only with a specified extension

index.js

const fullPaths = new FullPath.Search({
    'path': '/example',
    'dirname': __dirname,
    'ext': 'md'
});

Run the app:

node index.js

gives the following output

[ 'your_current_working_directory/example/nested/nested-a/a1/empty.md',
  'your_current_working_directory/example/nested/nested-b/b1/empty.md',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.md',
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211/empty.md' ]

Example 5 - Exclude folders (also you can select with a extension or not)

index.js

 const fullPaths = new FullPath.Search({
    'path': '/example',
    'dirname': __dirname,
    'ext': 'md', //it's not mandatory
    'exc': ['nested-b', 'a1']
});

Run the app:

node index.js

gives the following output

[ '/home/davidenq/Code/fullpath/test/example/nested/nested-a/empty.md',
  '/home/davidenq/Code/fullpath/test/example/nested/nested-a/a2/a21/a211/empty.md' ]

Run test

$ npm test

Support

If you need help using fullpath, or have found a bug, please create an issue on the GitHub repo.

License

MIT Licence

#Versión Español

#fullpath

Un módulo para node.js que obtiene la ruta de acceso completa de una carpeta y sus carpetas anidadas o la ruta completa de todos los archivos contenidos en cada carpeta anidada.

notas de la versión:

  • el módulo fullpath ahora soporta dos nuevas caraceterísticas: excluir carpetas y seleccionar archivos con una extensión especificada. Por favor, ver los ejemplos 4 y 5 para mayor información acerca de como usar estas nuevas características.

###Instalación

$ [sudo] npm install fullpath --save

###¿Cómo usar?

A continuación se muestra un ejemplo sencillo de la ejecución del módulo.

Estructura de la carpeta (folder):


├── example/
│   ├── empty /
│   ├── nested /
│   │   ├── nested-a/
│   │   │   ├── a1/
│   │   │   │   ├── empty.js
│   │   │   ├── a2/
│   │   │   │   ├── a21/
│   │   │   │   │   ├── a211/
│   │   │   │   │   │   ├── empty.js
│   │   │   │   │   │   ├── example.js
│   │   ├── nested-b/
│   │   │   ├── b1/
│   │   │   │   ├── b11/
│   │   │   │   │   ├── empty.js
│   │   │   │   │   ├── empty.json
│   │   │   │   ├── empty.js
├── index.js

Ejemplo 1 - Ruta completa de los directorios

index.js

const fullPaths = new FullPath.Search({
    'path': '/example',
    'dirname': __dirname,
    'type': 'files',   //opcional. Si no especifica este valor, por defecto el valor será seteado con 'files'
    'allFiles': false //optional. Si no especifica este valor, por defecto dicho valor será seteado con false y obtendrá el resultado las rutas complestas únicamente de 
                      // archivos con extensión .json y .js
});

Ejecutar la app:

node index.js

El resultado es:

[ 'your_current_working_directory/example/empty',
  'your_current_working_directory/example/nested',
  'your_current_working_directory/example/nested/nested-a',
  'your_current_working_directory/example/nested/nested-b',
  'your_current_working_directory/example/nested/nested-a/a1',
  'your_current_working_directory/example/nested/nested-a/a2',
  'your_current_working_directory/example/nested/nested-b/b1',
  'your_current_working_directory/example/nested/nested-a/a2/a21',
  'your_current_working_directory/example/nested/nested-b/b1/b11',
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211' ]

Ejemplo 2 - Ruta completa de archivos con cualquier extensión

index.js

const fullPaths = new FullPath.Search({
    'path': '/example',
    'dirname': __dirname,
    'type': 'files',   //opcional. Si no especifica este valor, por defecto el valor será seteado con 'files'
    'allFiles': true //optional. Si no especifica este valor, por defecto dicho valor será seteado con false y obtendrá el resultado las rutas complestas únicamente de 
                      // archivos con extensión .json y .js
});

Ejecutar la app:

node index.js

El resultado es:

[ 'your_current_working_directory/example/nested/nested-a/a1/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.json',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.md', // .md
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211/empty.js',
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211/example.js' ]

Ejemplo 3 - Ruta completa de archivos únicamente con extensión .json y .js.

index.js

const fullPaths = new FullPath.Search({
    'path': '/example',
    'dirname': __dirname,
    'type': 'files',   //opcional. Si no especifica este valor, por defecto el valor será seteado con 'files'
    'allFiles': false //optional. Si no especifica este valor, por defecto dicho valor será seteado con false y obtendrá el resultado las rutas complestas únicamente de 
                      // archivos con extensión .json y .js
});

Ejecutar la app:

node index.js

El resultado es:

[ 'your_current_working_directory/example/nested/nested-a/a1/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.js',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.json',
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211/empty.js',
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211/example.js' ]

Ejemplo 4 - Ruta completa de archivos con una extensión especificada

index.js

const fullPaths = new FullPath.Search({
    'path': '/example',
    'dirname': __dirname,
    'ext': 'md'
});

Ejecutar la app:

node index.js

gives the following output

[ 'your_current_working_directory/example/nested/nested-a/a1/empty.md',
  'your_current_working_directory/example/nested/nested-b/b1/empty.md',
  'your_current_working_directory/example/nested/nested-b/b1/b11/empty.md',
  'your_current_working_directory/example/nested/nested-a/a2/a21/a211/empty.md' ]

Ejemplo 5 - Excluir carpetas (también puedes elegir o no archivos con una extensión especifica)

index.js

 const fullPaths = new FullPath.Search({
    'path': '/example',
    'dirname': __dirname,
    'ext': 'md', //it's not mandatory
    'exc': ['nested-b', 'a1']
});

Ejecutar la app:

node index.js

gives the following output

[ '/home/davidenq/Code/fullpath/test/example/nested/nested-a/empty.md',
  '/home/davidenq/Code/fullpath/test/example/nested/nested-a/a2/a21/a211/empty.md' ]

Ejecutar pruebtas

$ npm test

Soporte

Si necesitas ayuda usando el módulo fullpath, o si encuentras un bug, por favor crea un issue en GitHub repo.

Licencia

MIT Licence