Dashboard sipadu mbip
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Assert.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. let assert = require('assert');
  2. let Dependencies = require('./Dependencies');
  3. let argv = require('yargs').argv;
  4. class Assert {
  5. /**
  6. * Assert that the call the mix.js() is valid.
  7. *
  8. * @param {*} entry
  9. * @param {*} output
  10. */
  11. static js(entry, output) {
  12. assert(
  13. typeof entry === 'string' || Array.isArray(entry),
  14. 'mix.js() is missing required parameter 1: entry'
  15. );
  16. assert(
  17. typeof output === 'string',
  18. 'mix.js() is missing required parameter 2: output'
  19. );
  20. }
  21. /**
  22. * Assert that the calls to mix.sass() and mix.less() are valid.
  23. *
  24. * @param {string} type
  25. * @param {string} src
  26. * @param {string} output
  27. */
  28. static preprocessor(type, src, output) {
  29. assert(
  30. typeof src === 'string',
  31. `mix.${type}() is missing required parameter 1: src`
  32. );
  33. assert(
  34. typeof output === 'string',
  35. `mix.${type}() is missing required parameter 2: output`
  36. );
  37. }
  38. /**
  39. * Assert that calls to mix.combine() are valid.
  40. *
  41. * @param {string} src
  42. * @param {File} output
  43. */
  44. static combine(src, output) {
  45. assert(
  46. output.isFile(),
  47. 'mix.combine() requires a full output file path as the second argument.'
  48. );
  49. }
  50. /**
  51. * Assert that the given file exists.
  52. *
  53. * @param {string} file
  54. */
  55. static exists(file) {
  56. assert(
  57. File.exists(file),
  58. `Whoops, you are trying to compile ${file}, but that file does not exist.`
  59. );
  60. }
  61. /**
  62. * Assert that the necessary dependencies are available.
  63. *
  64. * @param {Array} list
  65. * @param {Boolean} abortOnComplete
  66. */
  67. static dependencies(dependencies, abortOnComplete = false) {
  68. if (argv['$0'].includes('ava')) return;
  69. new Dependencies(dependencies).install(abortOnComplete);
  70. }
  71. }
  72. module.exports = Assert;