Skip to content

Commit 5387d12

Browse files
committed
Init
1 parent 3d32430 commit 5387d12

File tree

7 files changed

+1062
-60
lines changed

7 files changed

+1062
-60
lines changed

.gitignore

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,2 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
8-
# Runtime data
9-
pids
10-
*.pid
11-
*.seed
12-
*.pid.lock
13-
14-
# Directory for instrumented libs generated by jscoverage/JSCover
15-
lib-cov
16-
17-
# Coverage directory used by tools like istanbul
18-
coverage
19-
20-
# nyc test coverage
21-
.nyc_output
22-
23-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24-
.grunt
25-
26-
# Bower dependency directory (https://bower.io/)
27-
bower_components
28-
29-
# node-waf configuration
30-
.lock-wscript
31-
32-
# Compiled binary addons (https://nodejs.org/api/addons.html)
33-
build/Release
34-
35-
# Dependency directories
1+
.idea
362
node_modules/
37-
jspm_packages/
38-
39-
# TypeScript v1 declaration files
40-
typings/
41-
42-
# Optional npm cache directory
43-
.npm
44-
45-
# Optional eslint cache
46-
.eslintcache
47-
48-
# Optional REPL history
49-
.node_repl_history
50-
51-
# Output of 'npm pack'
52-
*.tgz
53-
54-
# Yarn Integrity file
55-
.yarn-integrity
56-
57-
# dotenv environment variables file
58-
.env
59-
60-
# next.js build output
61-
.next

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
sudo: false
3+
node_js:
4+
- '8'
5+
- '9'
6+
- '10'

index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const path = require('path');
2+
const fs = require('fs-extra');
3+
4+
class SaveResourceToExistingDirectoryPlugin {
5+
apply (registerAction) {
6+
let absoluteDirectoryPath, loadedResources = [];
7+
8+
registerAction('beforeStart', ({options}) => {
9+
if (!options.directory || typeof options.directory !== 'string') {
10+
throw new Error(`Incorrect directory ${options.directory}`);
11+
}
12+
13+
absoluteDirectoryPath = path.resolve(process.cwd(), options.directory);
14+
});
15+
16+
registerAction('saveResource', async ({resource}) => {
17+
const filename = path.join(absoluteDirectoryPath, resource.getFilename());
18+
const text = resource.getText();
19+
await fs.outputFile(filename, text, { encoding: 'binary' });
20+
loadedResources.push(resource);
21+
});
22+
}
23+
}
24+
25+
module.exports = SaveResourceToExistingDirectoryPlugin;

0 commit comments

Comments
 (0)