5
5
*
6
6
* node add-random-posts.js https://blah.ghost.io ADMIN_API_KEY number_of_posts
7
7
*/
8
- if ( process . argv . length < 4 ) {
8
+ if ( process . argv . length < 5 ) {
9
9
console . error ( 'Missing an argument' ) ;
10
10
process . exit ( 1 ) ;
11
11
}
@@ -25,35 +25,35 @@ const api = new GhostAdminAPI({
25
25
url,
26
26
key,
27
27
version : 'v2'
28
- } ) ;
28
+ } ) ;
29
29
30
30
( async function main ( ) {
31
31
try {
32
- const posts = [ ] ;
32
+ const posts = [ ] ;
33
33
34
34
_ . times ( count , ( ) => {
35
35
let post = {
36
36
status : 'published' ,
37
37
title : loremIpsum ( {
38
38
count : 2 ,
39
- units : 'words' ,
39
+ units : 'words'
40
40
} ) ,
41
41
excerpt : loremIpsum ( {
42
42
count : 2 ,
43
43
units : 'sentences'
44
44
} ) ,
45
45
html : loremIpsum ( {
46
- count : 400 , // Number of "words", "sentences", or "paragraphs"
47
- format : 'html' , // "plain" or "html"
48
- paragraphLowerBound : 3 , // Min. number of sentences per paragraph.
49
- paragraphUpperBound : 7 , // Max. number of sentences per paragarph.
50
- random : Math . random , // A PRNG function
51
- sentenceLowerBound : 3 , // Min. number of words per sentence.
52
- sentenceUpperBound : 15 , // Max. number of words per sentence.
53
- suffix : '\n' , // Line ending, defaults to "\n" or "\r\n" (win32)
54
- units : 'paragraphs' , // paragraph(s), "sentence(s)", or "word(s)"
55
- words : undefined // Array of words to draw from
56
- } ) ,
46
+ count : 400 , // Number of "words", "sentences", or "paragraphs"
47
+ format : 'html' , // "plain" or "html"
48
+ paragraphLowerBound : 3 , // Min. number of sentences per paragraph.
49
+ paragraphUpperBound : 7 , // Max. number of sentences per paragarph.
50
+ random : Math . random , // A PRNG function
51
+ sentenceLowerBound : 3 , // Min. number of words per sentence.
52
+ sentenceUpperBound : 15 , // Max. number of words per sentence.
53
+ suffix : '\n' , // Line ending, defaults to "\n" or "\r\n" (win32)
54
+ units : 'paragraphs' , // paragraph(s), "sentence(s)", or "word(s)"
55
+ words : undefined // Array of words to draw from
56
+ } )
57
57
58
58
} ;
59
59
@@ -64,7 +64,6 @@ const api = new GhostAdminAPI({
64
64
65
65
// convert our list of posts, to a list of promises for requests to the api
66
66
const result = await Promise . mapSeries ( posts , async ( post ) => {
67
-
68
67
console . log ( 'Adding' , post . title ) ;
69
68
// Call the API
70
69
let result = await api . posts . add ( post , { source : 'html' } ) ;
@@ -74,7 +73,6 @@ const api = new GhostAdminAPI({
74
73
} ) ;
75
74
76
75
console . log ( `Added ${ result . length } posts` ) ;
77
-
78
76
} catch ( err ) {
79
77
console . error ( 'There was an error' , require ( 'util' ) . inspect ( err , false , null ) ) ;
80
78
process . exit ( 1 ) ;
0 commit comments