Comparing version 0.2.0 to 0.3.0
'use strict'; | ||
jest.unmock('../lib/container'); | ||
jest.mock('fs'); | ||
jest.unmock('../lib/main'); | ||
describe('Container', () => { | ||
let fs; | ||
let rc; | ||
// TODO: write some tests | ||
beforeEach(() => { | ||
fs = require('fs'); | ||
rc = require('../'); | ||
fs.writeFileSync('res/container/'); | ||
fs.writeFileSync('res/container/package.json', JSON.stringify({ | ||
package_version: rc.tools.spec.version | ||
})); | ||
fs.writeFileSync('res/container/content/config.yml', '---'); | ||
}); | ||
it('should load a container', () => { | ||
let container_path = 'res/container'; | ||
return rc.load(container_path) | ||
.then(function(container) { | ||
expect(container.path).toEqual(container_path); | ||
}); | ||
}); | ||
}); |
@@ -20,2 +20,4 @@ 'use strict'; | ||
const content_dir = 'content'; | ||
/** | ||
@@ -48,3 +50,3 @@ * Returns a properly formatted container slug. | ||
try { | ||
config_yaml = fs.readFileSync(path.join(container_directory, 'config.yml')); | ||
config_yaml = fs.readFileSync(path.join(container_directory, content_dir, 'config.yml')); | ||
} catch (err){ | ||
@@ -168,3 +170,3 @@ console.error(err); | ||
if(fileUtils.fileExists(container_archive)) { | ||
return loadContainer(container_directory, opts); | ||
return loadContainer(container_directory); | ||
} | ||
@@ -247,2 +249,4 @@ if(opts.compression_method === 'zip') { | ||
type: props.container_type, | ||
// TRICKY: resource.modified_at comes from the format.modified_at in resource.formats. | ||
// we assume this to have been normalized before hand. | ||
modified_at: props.resource.modified_at, | ||
@@ -419,2 +423,16 @@ content_mime_type: mimeType, | ||
/** | ||
* Reads the resource container info without opening it. | ||
* | ||
* @param container_path {string} path to the container archive or directory | ||
* @returns {Promise.<{}>} the resource container info (package.json) | ||
*/ | ||
function inspectContainer(container_path) { | ||
return new Promise(function(resolve, reject) { | ||
// TODO: look in the container and get the package info | ||
throw new Error('Not implemented'); | ||
// return {}; | ||
}); | ||
} | ||
module.exports = { | ||
@@ -426,2 +444,3 @@ load: loadContainer, | ||
tools: { | ||
inspect: inspectContainer, | ||
convertResource: convertResource, | ||
@@ -428,0 +447,0 @@ makeSlug: containerSlug, |
{ | ||
"name": "door43-rc", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "A utility for managing Door43 Resource Containers", | ||
"main": "./lib/container.js", | ||
"main": "./lib/main.js", | ||
"scripts": { | ||
@@ -7,0 +7,0 @@ "test": "jest" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33466
13
831
4