question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugin method install() runs before setOptions()

See original GitHub issue

This breaks plugins like less-plugin-autoprefix in Less v3.x.

Test Plugin

less-plugin-test/index.js in global node_modules:

module.exports = {
	install: function (less, pluginManager) {
		console.group('running install()')
		console.log('this.options:', this.options)
		console.groupEnd()
	},
	setOptions: function(options) {
		console.group('running setOptions()')
		this.options = options
		console.log('this.options:', this.options)
		console.groupEnd()
	},
}

Less 2.x

npm i -g less@2 && lessc --test="test" empty.less

Result:

running setOptions()
  this.options: test
running install()
  this.options: test

Less 3.x (including 3.5.0-beta)

npm i -g less@3.5.0-beta && lessc --test="test" empty.less

Result:

running install()
  this.options: undefined
running setOptions()
  this.options: test

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
matthew-deancommented, Jun 30, 2018

Okay, I merged, so I’ll close this.

0reactions
calvinjuarezcommented, Jun 30, 2018

Yup, this fixes less-plugin-autoprefix. I’m gonna quick look into maybe only doing the double-run for plugins with minimum version < 3, but I don’t think this should wait for that, since it’s possibly getting in the way of people’s workflows.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preferences Capacitor Plugin API
The Preferences API provides a simple key/value persistent store for lightweight data.
Read more >
update_option() | Function - WordPress Developer Resources
This function is designed to work with or without a logged-in user. In terms of security, plugin developers should check the current user's...
Read more >
Guide to Developing Java Plugins - Apache Maven
Your First Plugin. In this section we will build a simple plugin with one goal which takes no parameters and simply displays a...
Read more >
MediaCodec - Android Developers
Call stop() to return the codec to the Uninitialized state, whereupon it may ... Running. End of Stream. Error. Released. SDK Version. State,...
Read more >
Command Line Usage - Less CSS
Pre-loading plugins is necessary if you want to add a Less.js Pre-processor. That is, a plugin that gets called and passed the raw...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found