Fix up atom package

master
James Long 2017-01-09 23:44:12 -05:00
parent dd8dda101d
commit b553718aee
3 changed files with 24 additions and 19 deletions

View File

@ -71,8 +71,12 @@ module.exports = {
if (!editor.getBuffer().isModified()) if (!editor.getBuffer().isModified())
return; return;
// var formatOnSave = atom.config.get('prettier.formatOnSave', {scope: editor.getRootScopeDescriptor()}) var formatOnSave = atom.config.get("prettier-atom.formatOnSave", {
// if (!formatOnSave) return scope: editor.getRootScopeDescriptor()
});
if (!formatOnSave)
return;
// Set the relative path based on the file's nearest package.json. // Set the relative path based on the file's nearest package.json.
// If no package.json is found, use path verbatim. // If no package.json is found, use path verbatim.
var relativePath; var relativePath;
@ -88,17 +92,18 @@ module.exports = {
} }
}.bind(this) }.bind(this)
); );
// Uncomment this to format on resize. Not ready yet. :)
if (editor.editorElement) { //
window.addEventListener("resize", e => { // if (editor.editorElement) {
const { width } = window.document.body.getBoundingClientRect(); // window.addEventListener("resize", e => {
const columns = width / // const { width } = window.document.body.getBoundingClientRect();
editor.editorElement.getDefaultCharacterWidth() | // const columns = width /
0; // editor.editorElement.getDefaultCharacterWidth() |
console.log(width, columns); // 0;
this.format({ selection: false, printWidth: columns }); // console.log(width, columns);
}); // this.format({ selection: false, printWidth: columns });
} // });
// }
}, },
config: { formatOnSave: { type: "boolean", default: false } } config: { formatOnSave: { type: "boolean", default: false } }
}; };

View File

@ -1,21 +1,21 @@
{ {
"name": "jscodefmt-atom", "name": "prettier-atom",
"main": "./lib/jscodefmt.js", "main": "./lib/prettier.js",
"version": "0.0.1", "version": "0.0.1",
"description": "Format file contents using jscodefmt", "description": "Format file contents using prettier",
"keywords": [ "keywords": [
"javascript", "javascript",
"formatter" "formatter"
], ],
"activationCommands": [], "activationCommands": [],
"repository": "https://github.com/stephenkubovic/atom-standard-formatter", "repository": "https://github.com/jlongster/prettier",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"atom": ">=0.174.0 <2.0.0" "atom": ">=0.174.0 <2.0.0"
}, },
"dependencies": { "dependencies": {
"find-root": "^0.1.1", "find-root": "^0.1.1",
"jscodefmt": "^0.0.1" "prettier": "0.0.2"
}, },
"devDependencies": {} "devDependencies": {}
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "prettier", "name": "prettier",
"version": "0.0.1", "version": "0.0.2",
"bin": { "bin": {
"prettier": "./bin/prettier" "prettier": "./bin/prettier"
}, },