Skip to content

Commit b9f7c53

Browse files
committed
Add An Installation Script
This scripts creates a storage adapter diretory and exports the firebase storage adapter
1 parent a123f48 commit b9f7c53

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"scripts": {
1515
"build": "tsc",
1616
"prepare": "npm run build",
17-
"lint": "eslint '*/**/*.ts' --quiet --fix"
17+
"lint": "eslint '*/**/*.ts' --quiet --fix",
18+
"install": "node ./lib/postinstall.js"
1819
},
1920
"license": "MIT",
2021
"devDependencies": {

src/postinstall.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { existsSync, mkdirSync, appendFileSync } from 'fs';
2+
import { join } from 'path';
3+
4+
const adapterDir = 'content/adapters/storage';
5+
6+
(function setupStorageAdapter(adapterDir: string) {
7+
try {
8+
// create storage adapter inside the storage adapter directory
9+
if (existsSync(join(adapterDir, 'firebase.js'))) {
10+
console.warn('A firebase.js exists in the storage adapter directory. Please setup manually!');
11+
return;
12+
}
13+
if (!existsSync(join(__dirname, adapterDir))) {
14+
mkdirSync(adapterDir, { recursive: true });
15+
}
16+
const content = `'use strict'\n\nmodule.exports = require('ghost-firebase-storage-adapter');\n`;
17+
appendFileSync(join(adapterDir, 'firebase.js'), content);
18+
// add configs to the dev settings
19+
} catch (error) {
20+
console.error(error);
21+
}
22+
})(adapterDir);

0 commit comments

Comments
 (0)