• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scriptype / writ-cms / 21049318970

15 Jan 2026 10:59PM UTC coverage: 38.215%. Remained the same
21049318970

push

github

scriptype
Fix sorting projects by mtime

621 of 3681 branches covered (16.87%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

2171 of 3625 relevant lines covered (59.89%)

1727.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/cms/api/models/workspace.js
1
const { homedir } = require('os')
×
2
const { join } = require('path')
×
3
const { mkdir, readdir, stat } = require('fs/promises')
×
4

5
const createWorkspaceModel = (state) => {
×
6
  const directoryName = 'writ projects'
×
7
  const directoryPath = join(homedir(), directoryName)
×
8

9
  const createProject = async (name) => {
×
10
    const path = join(directoryPath, name)
×
11
    const stats = await stat(path)
×
12
    return {
×
13
      name,
14
      path,
15
      dateModified: stats.mtime
16
    }
17
  }
18

19
  return {
×
20
    async get() {
21
      try {
×
22
        const directory = await readdir(directoryPath, { withFileTypes: true })
×
23
        const isProject = item => item.isDirectory()
×
24
        const projects = await Promise.all(
×
25
          directory
26
            .filter(isProject)
27
            .map(item => createProject(item.name))
×
28
        )
UNCOV
29
        return {
×
NEW
30
          projects: projects.sort((a, b) => b.dateModified - a.dateModified)
×
31
        }
32
      } catch (e) {
33
        return {}
×
34
      }
35
    },
36

37
    async create() {
38
      try {
×
39
        console.log('api.workspace.creating workspace folder')
×
40
        await mkdir(directoryPath)
×
41
      } catch (e) {
42
        if (e.code !== 'EEXIST') {
×
43
          console.log('api.workspace.create.error', e)
×
44
          throw e
×
45
        }
46
        console.log('workspace already exists')
×
47
      }
48
      return this.get()
×
49
    },
50

51
    async createProject({ name }) {
52
      await this.create()
×
53
      const path = join(directoryPath, name)
×
54
      await mkdir(path)
×
55
      return createProject(name)
×
56
    }
57
  }
58
}
59

60
module.exports = createWorkspaceModel
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc