-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
92 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const { readFile, writeFile, exists } = require('../file-gateway') | ||
const { CONFIG_DIR } = require('../../constants') | ||
const { loadYAML, dumpYAML } = require('../yaml') | ||
const _path = require('path') | ||
|
||
module.exports = { | ||
load, | ||
save | ||
} | ||
|
||
async function load(projectPath) { | ||
const tagsPath = getTagsPath(projectPath) | ||
if (!(await exists(tagsPath))) return | ||
const tagsData = await readFile(tagsPath, 'utf-8') | ||
try { | ||
const { tags } = loadYAML(tagsData) | ||
return tags | ||
} catch (e) { | ||
console.error(e) | ||
return | ||
} | ||
} | ||
|
||
async function save(tags, projectPath) { | ||
await writeFile(getTagsPath(projectPath), dumpYAML({ tags })) | ||
} | ||
|
||
function getTagsPath(projectPath) { | ||
return _path.join(projectPath, CONFIG_DIR, 'tags.yml') | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const Plugin = require('imdone-api') | ||
const { save } = require('../adapters/storage/tags.js') | ||
|
||
module.exports = class PersistTagsPlugin extends Plugin { | ||
constructor(project) { | ||
super(project) | ||
} | ||
|
||
async onBoardUpdate() { | ||
await save(this.project.allTags, this.project.path) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const expect = require('expect.js'); | ||
const path = require('path'); | ||
const { | ||
getFreshRepo | ||
} = require('../../../test/helper') | ||
const { | ||
getTags | ||
} = require('../get-project-tags.js') | ||
|
||
const { createFileSystemProject } = require('../../project-factory.js') | ||
|
||
describe('get-project-tags', () => { | ||
it('should return a list of tags', async () => { | ||
// Given | ||
const repoPath = getFreshRepo('default-cards'); | ||
const project = createFileSystemProject({ path: repoPath }); | ||
await project.init(); | ||
project.toImdoneJSON(); | ||
const filePath = path.join(repoPath, 'imdone-readme.md'); | ||
// When | ||
const tags = await getTags(filePath); | ||
// Then | ||
expect(tags.length).to.be(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { | ||
load, | ||
save | ||
} = require('../adapters/storage/tags.js') | ||
|
||
const { | ||
findImdonePath | ||
} = require('../adapters/storage/config.js') | ||
|
||
module.exports = { | ||
getTags | ||
} | ||
|
||
async function getTags(filePath) { | ||
const projectPath = await findImdonePath(filePath) | ||
return load(projectPath) | ||
} |