Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

riot-cli

Package Overview
Dependencies
Maintainers
3
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

riot-cli - npm Package Compare versions

Comparing version 2.3.1 to 2.3.12

test/expected/export/tags.css

2

lib/analyzer/index.js

@@ -36,3 +36,3 @@ 'use strict'

function analyze(source) {
var mode = 'outside',// outside | tag_start | tag | tag_end | template | script | style
var mode = 'outside', // outside | tag_start | tag | tag_end | template | script | style
tag = '',

@@ -39,0 +39,0 @@ results

@@ -25,6 +25,9 @@ 'use strict'

* @param { String } base - base path
* @param { String } extension - base path
* @returns { Array } array containing all the paths to the new files that must be created
*/
remap(extRegex, from, to, base) {
return from.map((from) => path.join(to, path.relative(base, from).replace(extRegex, '.js')) )
remap(extRegex, from, to, base, extension) {
return from
.map((from) => path.join(to, path.relative(base, from)
.replace(extRegex, `.${extension || 'js'}`)))
},

@@ -31,0 +34,0 @@ /**

@@ -66,5 +66,7 @@ #!/usr/bin/env node

compact: args.compact,
template: args.template,
type: args.type,
template: args.template, // html preprocessor
style: args.style, // css preprocessor
type: args.type, // javascript preprocessor
brackets: args.brackets,
entities: !!args.export,
expr: args.expr,

@@ -77,2 +79,3 @@ modular: args.modular,

css: args.css,
export: args.export,
colors: args.colors,

@@ -79,0 +82,0 @@ from: args._.shift(),

@@ -26,2 +26,3 @@ const helpers = require('./helpers')

riot test.tag --type coffeescript --expr
riot test.tag --style sass --export css test.css

@@ -56,2 +57,10 @@ Version ${ helpers.getVersion() }

{
option: 'export',
type: 'String',
alias: 'e',
description: 'Compile and export only the css or html or js from your tags',
example: 'riot test.tag --export css test.css',
enum: ['css', 'js', 'html']
},
{
option: 'type',

@@ -85,2 +94,8 @@ alias: 't',

{
option: 'style',
type: 'String',
description: 'Css pre-processor. Built-in support for: sass, scss, less, stylus',
example: 'riot test.tag --style scss'
},
{
option: 'whitespace',

@@ -87,0 +102,0 @@ type: 'Boolean',

@@ -7,3 +7,7 @@ 'use strict'

sh = require('shelljs'),
NO_FILE_FOUND = 'Source path does not exist'
compiler = global.compiler || require('riot-compiler'),
NO_FILE_FOUND = 'Source path does not exist',
PREPROCESSOR_NOT_FOUND = function(type, id) {
return `The "${id}" ${type} preprocessor was not found. Have you installed it locally?`
}

@@ -20,7 +24,8 @@ /**

this.called = true
this.error = false
// validate the compiler options
this.error = opt.compiler ? this.validate(opt.compiler) : false
// create a regex to figure out whether our user
// wants to compile a single tag or some tags in a folder
this.extRegex = new RegExp('\\.' + (opt.ext || 'tag') + '$')
this.extRegex = new RegExp(`\\.${opt.ext || 'tag' }$`)

@@ -36,12 +41,11 @@ // If no target dir, default to source dir

// Throw if source path doesn't exist
// Check if the path exsists
if (!sh.test('-e', opt.from)) this.error = NO_FILE_FOUND
if (!sh.test('-e', opt.from)) {
// throw the error only in the cli
if (this.error) {
/* istanbul ignore next */
if (opt.isCli)
helpers.err(NO_FILE_FOUND)
else {
this.error = NO_FILE_FOUND
return
}
helpers.err(this.error)
else return this.error
}

@@ -55,3 +59,3 @@

// [file, file]
opt.flow = (this.extRegex.test(opt.from) ? 'f' : 'd') + (/\.js$/.test(opt.to) ? 'f' : 'd')
opt.flow = (this.extRegex.test(opt.from) ? 'f' : 'd') + (/\.(js|html|css)$/.test(opt.to) ? 'f' : 'd')

@@ -65,4 +69,29 @@ // make sure to set always the compiler options

}
/**
* Check whether the parser is available
* @param { String } name - parser id ( the require call )
* @returns {Boolean} - have you this node dependency locally installed?
*/
has(name) {
return !!compiler.parsers._req(name)
}
/**
* Validate the compiler options checking whether the local dependencies
* are installed
* @param { Object } opt - compiler options
* @returns {String|Boolean} - false if there are no errors
*/
validate(opt) {
var template = opt.template,
type = opt.type
if (template && !this.has(template))
return PREPROCESSOR_NOT_FOUND('html', template)
else if (type && !this.has(type))
return PREPROCESSOR_NOT_FOUND('javascript', type)
return false
}
}
module.exports = Task

@@ -33,3 +33,3 @@ 'use strict'

base = opt.flow[0] == 'f' ? path.dirname(opt.from) : opt.from,
to = opt.flow[1] == 'f' ? [opt.to] : helpers.remap(this.extRegex, from, opt.to, base)
to = opt.flow[1] == 'f' ? [opt.to] : helpers.remap(this.extRegex, from, opt.to, base, opt.export)

@@ -101,3 +101,5 @@ // Create any necessary dirs

}
return out
if (opt.export)
return out.reduce((prev, curr) => prev + curr[opt.export], '')
else return out
}

@@ -104,0 +106,0 @@ /**

{
"name": "riot-cli",
"version": "2.3.1",
"version": "2.3.12",
"description": "Riot command line utility",

@@ -28,6 +28,6 @@ "main": "lib/index.js",

"coveralls": "^2.11.4",
"eslint": "^1.7.0",
"eslint": "^1.10.1",
"expect.js": "^0.3.1",
"istanbul": "^0.4.0",
"mocha": "^2.3.3"
"mocha": "^2.3.4"
},

@@ -42,3 +42,3 @@ "license": "MIT",

"chalk": "^1.1.1",
"chokidar": "^1.2.0",
"chokidar": "^1.3.0",
"optionator": "^0.6.0",

@@ -45,0 +45,0 @@ "riot-compiler": "^2.3.*",

require('shelljs/global')
const TAGS_FOLDER = 'test/tags',
EXPECTED_FOLDER = 'test/expected',
GENERATED_FOLDER = 'test/generated',

@@ -42,6 +43,6 @@ cli = require('../../lib')

expect(cli.make).withArgs({
expect(cli.make({
from: `${TAGS_FOLDER}/component.tag`,
compiler: { modular: true, template: 'nope' }
}).to.throwError()
}).error).to.be('The "nope" html preprocessor was not found. Have you installed it locally?')

@@ -57,2 +58,47 @@ // check if the file exists

it('make using the --export feature', function() {
cli.make({
from: `${TAGS_FOLDER}/export`,
to: `${GENERATED_FOLDER}/export/make-tags.html`,
export: 'html',
compiler: {
entities: true
}
})
expect(cat(`${GENERATED_FOLDER}/export/make-tags.html`)).to.be(cat(`${EXPECTED_FOLDER}/export/tags.html`))
cli.make({
from: `${TAGS_FOLDER}/export`,
to: `${GENERATED_FOLDER}/export/make-tags.js`,
export: 'js',
compiler: {
entities: true
}
})
expect(cat(`${GENERATED_FOLDER}/export/make-tags.js`)).to.be(cat(`${EXPECTED_FOLDER}/export/tags.js`))
cli.make({
from: `${TAGS_FOLDER}/export`,
to: `${GENERATED_FOLDER}/export/make-tags.css`,
export: 'css',
compiler: {
entities: true
}
})
expect(cat(`${GENERATED_FOLDER}/export/make-tags.css`)).to.be(cat(`${EXPECTED_FOLDER}/export/tags.css`))
cli.make({
from: `${TAGS_FOLDER}/export`,
to: `${GENERATED_FOLDER}/export/make-tags.scss.css`,
export: 'css',
ext: 'html',
compiler: {
style: 'sass',
entities: true
}
})
expect(cat(`${GENERATED_FOLDER}/export/make-tags.scss.css`).replace(/\n/g, '')).to.be(cat(`${EXPECTED_FOLDER}/export/tags.scss.css`).replace(/\n/g, ''))
})
it('watch folder', (done) => {

@@ -59,0 +105,0 @@ var watcher = cli.watch({from: TAGS_FOLDER})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc