Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore node_modules in globbing #45

Merged
merged 6 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
lib/
tmp/
node_modules/**
!/test/_files/node_modules/ignore.*

########## gitignore.io ##########
# Created by https://www.gitignore.io/api/node,windows,macos,linux,sublimetext,emacs,vim,visualstudiocode
Expand Down Expand Up @@ -128,7 +130,6 @@ bower_components
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
- Output the configured engine in `version` (`-v`) option ([#43](https://github.com/marp-team/marp-cli/pull/43))
- Experimental support `--preview` option to open preview window provided by [Carlo](https://github.com/GoogleChromeLabs/carlo) ([#44](https://github.com/marp-team/marp-cli/pull/44))

### Fixed

- Ignore `node_modules` in globbing ([#45](https://github.com/marp-team/marp-cli/pull/45))

## v0.0.14 - 2018-11-24

### Security
Expand Down
1 change: 1 addition & 0 deletions src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class File {
return (await globby(pathes, {
absolute: true,
expandDirectories: { files: markdownExtensions.map(ext => `*.${ext}`) },
ignore: ['**/node_modules'],
})).map(p => new File(p))
}

Expand Down
3 changes: 2 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ export class Server {
const { name, stat } = f
const directory = stat && stat.isDirectory()
const parent = name === '..' && directory
const nodeModules = name === 'node_modules' && directory
const convertible =
!parent && (await this.validateMarkdown(name, stat)).valid

files.push({ convertible, directory, name, parent, stat })
files.push({ convertible, directory, name, nodeModules, parent, stat })
}

callback(null, serverIndex({ directory, files, path, style }))
Expand Down
2 changes: 1 addition & 1 deletion src/server/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ html
h1= directory
ul.index
each file in files
li(class={ convertible: file.convertible, directory: file.directory })
li(class={ convertible: file.convertible, directory: file.directory, nodeModules: file.nodeModules })
a.link.file(href=encodeURIComponent(file.name))= file.name

if file.convertible
Expand Down
3 changes: 2 additions & 1 deletion src/server/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ ul.index {
background-image: url('./assets/icon-directory.svg');
}

&:not(.convertible):not(.directory) {
&:not(.convertible):not(.directory),
&.nodeModules {
display: none;
}

Expand Down
1 change: 1 addition & 0 deletions src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export class ThemeSet {
return await globby(fn, {
absolute: true,
expandDirectories: { files: themeExtensions },
ignore: ['**/node_modules'],
})
}
}
Expand Down
Empty file.
Empty file.
5 changes: 3 additions & 2 deletions test/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ describe('Server', () => {

const $ = cheerio.load(response.text)
expect($('h1').text()).toBe('/')
expect($('ul.index li')).toHaveLength(6) // Actual file count
expect($('ul.index li.directory')).toHaveLength(2) // Directories
expect($('ul.index li')).toHaveLength(7) // Actual file count
expect($('ul.index li.directory')).toHaveLength(3) // Directories
expect($('ul.index li.directory.nodeModules')).toHaveLength(1)
expect($('ul.index li.convertible')).toHaveLength(3) // Markdown files

// PDF query parameter
Expand Down