Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. # istanbul-lib-processinfo
  2. A utility for managing the `processinfo` folder that NYC uses.
  3. This is intended to be used along with [NYC](https://npm.im/nyc), but can also
  4. be used by other tools that wish to consume NYC's processinfo data.
  5. ## API
  6. ### class ProcessInfo
  7. A representation of information about a single process.
  8. #### constructor(fields)
  9. Pass in fields that will be printed to the processinfo file. Several defaults
  10. will be provided if not specified.
  11. #### async processInfo.save()
  12. Write this process info to disk. This works by passing the ProcessInfo object
  13. to JSON.stringify, and writing to `${this.directory}/${this.uuid}.json`.
  14. #### processInfo.saveSync()
  15. The synchronous version of `.save()`.
  16. #### async processInfo.getCoverageMap(nyc)
  17. Get a merged coverage map of the current process, as well as any child
  18. processes. This should only be called during tree rendering, as it depends on
  19. child nodes being present in the `nodes` array.
  20. The `nyc` instance is required to load the report information and apply
  21. sourcemaps properly.
  22. ### processInfo.label
  23. A read-only string for when archy prints the process tree.
  24. ### processInfo.nodes
  25. A list of the child nodes used during tree rendering.
  26. ### processInfo.directory
  27. If a process will be saved, it must have a `directory` included
  28. in the list of fields. This property is not saved to the processinfo file.
  29. ## class ProcessDB
  30. A utility for interacting with the collection of ProcessInfo files in the
  31. processinfo folder.
  32. ### constructor(directory)
  33. Supply the directory where processinfo files are found. This should be the
  34. full path, something like `${cwd}/.nyc_output/processinfo`.
  35. ### processDB.directory
  36. A read-only property showing the directory where this object is working.
  37. ### processDB.nodes
  38. A list of child ProcessInfo nodes used in tree printing.
  39. ### processDB.label
  40. The string `'nyc'`, used as the default root node in the archy tree rendering.
  41. ### async processDB.writeIndex()
  42. Create the `index.json` file in the processinfo folder, which is required for
  43. tree generation and expunging.
  44. WARNING: Index writing is non-atomic, and should not be performed by multiple
  45. processes.
  46. ### async processDB.readIndex()
  47. Read and return the contents of the `index.json` file. If the `index.json` is
  48. not present or not valid, then it will attempt to generate one.
  49. ### async processDB.readProcessInfos()
  50. Read all the data files in the processinfo folder, and return an object mapping
  51. the file basename to the resulting object. Used in tree generation.
  52. ### async processDB.renderTree(nyc)
  53. Render the tree as a string using archy, suitable for printing to the terminal.
  54. ### async processDB.buildProcessTree()
  55. Build the hierarchical tree of nodes for tree rendering. Populates the `nodes`
  56. array of this object and all `ProcessInfo` objects in the tree.
  57. ### async processDB.getCoverageMap(nyc)
  58. Used in tree rendering, to show the total coverage of all the processinfo files
  59. in the data folder.
  60. ### async processDB.spawn(name, file, args, options)
  61. Spawn a child process with a unique name provided by the caller. This name is
  62. stored as the `externalId` property in the child process's `ProcessInfo` data,
  63. and is tracked in the `externalIds` section of the index.
  64. Note that if the current process is not already wrapped by nyc, then you must
  65. prefix the spawned program with nyc, in order for this to take effect. For
  66. example, instead of `processDB.spawn('foo', 'node', ['foo.js'])`, you would run
  67. `processDB.spawn('foo', 'nyc', ['node', 'foo.js'])`.
  68. If a process with that name already exists in the index, then it will be
  69. expunged.
  70. Unlike `child_process.spawn` this function returns a Promise which resolves to
  71. the `ChildProcess` object.
  72. WARNING: Calling `expunge` (which this method does) will result in the index
  73. being out of date. It is the caller's responsibility to call
  74. `processDB.writeIndex()` when all named processes are completed.
  75. ### async processDB.expunge(name)
  76. If a process exists in the process info data folder with the specified name
  77. (ie, it had previously been run with `processDB.spawn(name, ...)`) then the
  78. coverage and processinfo files for it and all of its children are removed.
  79. This allows for a test harness to re-run or resume test suites, without
  80. spurious coverage results.
  81. WARNING: Calling `expunge` will result in the index being out of date. It is
  82. the caller's responsibility to call `processDB.writeIndex()` when all named
  83. processes are completed.
  84. ## DATA STRUCTURES and FILES
  85. ProcessInfo files MUST match the following structure:
  86. ```
  87. {
  88. "uuid": "UUID of the process itself",
  89. "parent": "UUID of the parent process, or null",
  90. "pid": Number,
  91. "ppid": Number (pid of parent process),
  92. "argv": Array<String>,
  93. "execArgv": Array<String>,
  94. "cwd": path,
  95. "time": Number (timestamp in ms),
  96. "coverageFilename": "Path to NYC coverage info for this process",
  97. "externalId": "The externally specified name for this process, or null",
  98. }
  99. ```
  100. The index file is saved to `${this.directory}/index.json`. It has
  101. the following structure:
  102. ```
  103. {
  104. "processes": {
  105. "<uuid>": {
  106. "parent": "parent uuid, or null",
  107. "children": ["children", "uuids", "or empty array"],
  108. "externalId": "externally specified name, if provided"
  109. },
  110. ...
  111. },
  112. "files": {
  113. "/path/to/covered/file.js": [
  114. "<uuids of processes that covered this file>",
  115. ...
  116. ],
  117. ...
  118. },
  119. "externalIds": {
  120. "externally specified name": {
  121. "root": "<uuid of process run under this name>",
  122. "children": [
  123. "<uuids of all descendant processes from this point in the tree>",
  124. ...
  125. ]
  126. },
  127. ...
  128. }
  129. }
  130. ```