@akemona-org/strapi-generate 3.7.0 → 3.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/generate.js CHANGED
@@ -160,7 +160,7 @@ function generate(generator, scope, cb) {
160
160
  );
161
161
  },
162
162
 
163
- err => {
163
+ (err) => {
164
164
  // Expose a `error` handler in generators.
165
165
  if (err) {
166
166
  const errorFn =
@@ -22,7 +22,7 @@ const fileHelper = require('../file');
22
22
  module.exports = function (options, cb) {
23
23
  cb = reportback.extend(cb, {
24
24
  alreadyExists: 'error',
25
- invalid: 'error'
25
+ invalid: 'error',
26
26
  });
27
27
 
28
28
  // Compute the canonical path to copy from
@@ -35,8 +35,11 @@ module.exports = function (options, cb) {
35
35
  return cb.error(err);
36
36
  }
37
37
 
38
- return fileHelper(_.merge(options, {
39
- contents
40
- }), cb);
38
+ return fileHelper(
39
+ _.merge(options, {
40
+ contents,
41
+ }),
42
+ cb
43
+ );
41
44
  });
42
45
  };
@@ -19,21 +19,17 @@ const reportback = require('reportback')();
19
19
 
20
20
  /* eslint-disable prefer-template */
21
21
  module.exports = function (options, cb) {
22
-
23
22
  // Provide default values for switchback.
24
23
  cb = reportback.extend(cb, {
25
- alreadyExists: 'error'
24
+ alreadyExists: 'error',
26
25
  });
27
26
 
28
27
  // Provide defaults and validate required options.
29
28
  _.defaults(options, {
30
- force: false
29
+ force: false,
31
30
  });
32
31
 
33
- const missingOpts = _.difference([
34
- 'contents',
35
- 'rootPath'
36
- ], Object.keys(options));
32
+ const missingOpts = _.difference(['contents', 'rootPath'], Object.keys(options));
37
33
 
38
34
  if (missingOpts.length) {
39
35
  return cb.invalid(missingOpts);
@@ -44,7 +40,7 @@ module.exports = function (options, cb) {
44
40
  const rootPath = path.resolve(process.cwd(), options.rootPath);
45
41
 
46
42
  // Only override an existing file if `options.force` is true.
47
- fs.exists(rootPath, exists => {
43
+ fs.exists(rootPath, (exists) => {
48
44
  if (exists && !options.force) {
49
45
  return cb.alreadyExists('Something else already exists at `' + rootPath + '`.');
50
46
  }
@@ -54,16 +50,19 @@ module.exports = function (options, cb) {
54
50
  return cb.success();
55
51
  }
56
52
 
57
- async.series([
58
- function deleteExistingFileIfNecessary(cb) {
59
- if (!exists) {
60
- return cb();
61
- }
62
- return fs.remove(rootPath, cb);
63
- },
64
- function writeToDisk(cb) {
65
- fs.outputFile(rootPath, options.contents, cb);
66
- }
67
- ], cb);
53
+ async.series(
54
+ [
55
+ function deleteExistingFileIfNecessary(cb) {
56
+ if (!exists) {
57
+ return cb();
58
+ }
59
+ return fs.remove(rootPath, cb);
60
+ },
61
+ function writeToDisk(cb) {
62
+ fs.outputFile(rootPath, options.contents, cb);
63
+ },
64
+ ],
65
+ cb
66
+ );
68
67
  });
69
68
  };
@@ -17,22 +17,19 @@ const reportback = require('reportback')();
17
17
  */
18
18
  /* eslint-disable prefer-template */
19
19
  module.exports = function (options, cb) {
20
-
21
20
  // Provide default values for cb.
22
21
  cb = reportback.extend(cb, {
23
22
  alreadyExists: 'error',
24
- invalid: 'error'
23
+ invalid: 'error',
25
24
  });
26
25
 
27
26
  // Provide defaults and validate required options.
28
27
  _.defaults(options, {
29
28
  force: false,
30
- gitkeep: false
29
+ gitkeep: false,
31
30
  });
32
31
 
33
- const missingOpts = _.difference([
34
- 'rootPath'
35
- ], Object.keys(options));
32
+ const missingOpts = _.difference(['rootPath'], Object.keys(options));
36
33
 
37
34
  if (missingOpts.length) {
38
35
  return cb.invalid(missingOpts);
@@ -41,7 +38,7 @@ module.exports = function (options, cb) {
41
38
  const rootPath = path.resolve(process.cwd(), options.rootPath);
42
39
 
43
40
  // Only override an existing folder if `options.force` is true.
44
- fs.lstat(rootPath, err => {
41
+ fs.lstat(rootPath, (err) => {
45
42
  const exists = !(err && err.code === 'ENOENT');
46
43
  if (exists && err) {
47
44
  return cb.error(err);
@@ -52,7 +49,7 @@ module.exports = function (options, cb) {
52
49
  }
53
50
 
54
51
  if (exists) {
55
- fs.remove(rootPath, err => {
52
+ fs.remove(rootPath, (err) => {
56
53
  if (err) {
57
54
  return cb.error(err);
58
55
  }
@@ -63,14 +60,13 @@ module.exports = function (options, cb) {
63
60
  }
64
61
 
65
62
  function _afterwards_() {
66
-
67
63
  // Don't actually write the directory if this is a dry run.
68
64
  if (options.dry) {
69
65
  return cb.success();
70
66
  }
71
67
 
72
68
  // Create the directory.
73
- fs.mkdirs(rootPath, err => {
69
+ fs.mkdirs(rootPath, (err) => {
74
70
  if (err) {
75
71
  return cb.error(err);
76
72
  }
@@ -18,21 +18,17 @@ const reportback = require('reportback')();
18
18
 
19
19
  /* eslint-disable prefer-template */
20
20
  module.exports = function (options, handlers) {
21
-
22
21
  // Provide default values for handlers.
23
22
  handlers = reportback.extend(handlers, {
24
- alreadyExists: 'error'
23
+ alreadyExists: 'error',
25
24
  });
26
25
 
27
26
  // Provide defaults and validate required options.
28
27
  _.defaults(options, {
29
- force: false
28
+ force: false,
30
29
  });
31
30
 
32
- const missingOpts = _.difference([
33
- 'rootPath',
34
- 'data'
35
- ], Object.keys(options));
31
+ const missingOpts = _.difference(['rootPath', 'data'], Object.keys(options));
36
32
 
37
33
  if (missingOpts.length) {
38
34
  return handlers.invalid(missingOpts);
@@ -41,13 +37,13 @@ module.exports = function (options, handlers) {
41
37
  const rootPath = path.resolve(process.cwd(), options.rootPath);
42
38
 
43
39
  // Only override an existing file if `options.force` is true.
44
- fs.exists(rootPath, exists => {
40
+ fs.exists(rootPath, (exists) => {
45
41
  if (exists && !options.force) {
46
42
  return handlers.alreadyExists('Something else already exists at `' + rootPath + '`.');
47
43
  }
48
44
 
49
45
  if (exists) {
50
- fs.remove(rootPath, err => {
46
+ fs.remove(rootPath, (err) => {
51
47
  if (err) {
52
48
  return handlers.error(err);
53
49
  }
@@ -58,7 +54,7 @@ module.exports = function (options, handlers) {
58
54
  }
59
55
 
60
56
  function _afterwards_() {
61
- fs.outputJSON(rootPath, options.data, {spaces: 2}, err => {
57
+ fs.outputJSON(rootPath, options.data, { spaces: 2 }, (err) => {
62
58
  if (err) {
63
59
  return handlers.error(err);
64
60
  } else {
@@ -23,7 +23,7 @@ const fileHelper = require('../file');
23
23
  module.exports = function (options, cb) {
24
24
  cb = reportback.extend(cb, {
25
25
  noTemplate: 'error',
26
- alreadyExists: 'error'
26
+ alreadyExists: 'error',
27
27
  });
28
28
 
29
29
  // Compute the canonical path to a template
@@ -49,7 +49,7 @@ module.exports = function (options, cb) {
49
49
 
50
50
  try {
51
51
  const compiled = _.template(contents, {
52
- interpolate: /<%=([\s\S]+?)%>/g
52
+ interpolate: /<%=([\s\S]+?)%>/g,
53
53
  });
54
54
  contents = compiled(options);
55
55
 
@@ -62,8 +62,11 @@ module.exports = function (options, cb) {
62
62
  return cb(e);
63
63
  }
64
64
 
65
- return fileHelper(_.merge(options, {
66
- contents
67
- }), cb);
65
+ return fileHelper(
66
+ _.merge(options, {
67
+ contents,
68
+ }),
69
+ cb
70
+ );
68
71
  });
69
72
  };
package/lib/target.js CHANGED
@@ -42,7 +42,7 @@ function generateTarget(options, cb) {
42
42
  () => {
43
43
  return isValidTarget(target) || ++_resolves > maxResolves;
44
44
  },
45
- asyncCb => {
45
+ (asyncCb) => {
46
46
  parseTarget(target, scope, (err, resolvedTarget) => {
47
47
  if (err) {
48
48
  return asyncCb(err);
@@ -51,7 +51,7 @@ function generateTarget(options, cb) {
51
51
  return asyncCb();
52
52
  });
53
53
  },
54
- err => {
54
+ (err) => {
55
55
  if (err) {
56
56
  return sb(err);
57
57
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.7.0",
6
+ "version": "3.7.2",
7
7
  "description": "Master of ceremonies for the Strapi generators.",
8
8
  "homepage": "https://strapi.akemona.com",
9
9
  "keywords": [
@@ -19,7 +19,7 @@
19
19
  "test": "echo \"no tests yet\""
20
20
  },
21
21
  "dependencies": {
22
- "@akemona-org/strapi-utils": "3.7.0",
22
+ "@akemona-org/strapi-utils": "3.7.2",
23
23
  "async": "^2.6.2",
24
24
  "fs-extra": "^9.1.0",
25
25
  "lodash": "4.17.21",
@@ -49,5 +49,5 @@
49
49
  "npm": ">=6.0.0"
50
50
  },
51
51
  "license": "SEE LICENSE IN LICENSE",
52
- "gitHead": "129a8d6191b55810fd66448dcc47fee829df986c"
52
+ "gitHead": "4ab59dbae5135819558c6ae27b45a556ff27cf55"
53
53
  }